# topological.sort

From igraph v0.5.1
by Gabor Csardi

##### Topological sorting of vertices in a graph

A topological sorting of a directed acyclic graph is a linear ordering of its nodes where each node comes before all nodes to which it has edges.

- Keywords
- graphs

##### Usage

`topological.sort(graph, mode=c("out", "all", "in"))`

##### Arguments

- graph
- The input graph, should be directed
- mode
- Specifies how to use the direction of the edges.
For
, the sorting order ensures that each node comes before all nodes to which it has edges, so nodes with no incoming edges go first. For`out`

`in`

##### Details

Every DAG has at least one topological sort, and may have many. This function returns a possible topological sort among them. If the graph is not acyclic (it has at least one cycle), a partial topological sort is returned and a warning is issued.

##### Value

- A numeric vector containing vertex ids in topologically sorted order.

##### concept

Topological sort

##### Examples

```
g <- barabasi.game(100)
topological.sort(g)
```

*Documentation reproduced from package igraph, version 0.5.1, License: GPL (>= 2)*

### Community examples

Looks like there are no examples yet.