1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/structural.properties.R
\name{topo_sort}
\alias{topo_sort}
\title{Topological sorting of vertices in a graph}
\usage{
topo_sort(graph, mode = c("out", "all", "in"))
}
\arguments{
\item{graph}{The input graph, should be directed}
\item{mode}{Specifies how to use the direction of the edges. For
\dQuote{\code{out}}, 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 \dQuote{\verb{in}}, it is quite the opposite: each node comes before all
nodes from which it receives edges. Nodes with no outgoing edges go first.}
}
\value{
A vertex sequence (by default, but see the \code{return.vs.es}
option of \code{\link[=igraph_options]{igraph_options()}}) containing vertices in
topologically sorted order.
}
\description{
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.
}
\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.
}
\examples{
g <- sample_pa(100)
topo_sort(g)
}
\seealso{
Other structural.properties:
\code{\link{bfs}()},
\code{\link{component_distribution}()},
\code{\link{connect}()},
\code{\link{constraint}()},
\code{\link{coreness}()},
\code{\link{degree}()},
\code{\link{dfs}()},
\code{\link{distance_table}()},
\code{\link{edge_density}()},
\code{\link{feedback_arc_set}()},
\code{\link{girth}()},
\code{\link{is_acyclic}()},
\code{\link{is_dag}()},
\code{\link{is_matching}()},
\code{\link{k_shortest_paths}()},
\code{\link{knn}()},
\code{\link{reciprocity}()},
\code{\link{subcomponent}()},
\code{\link{subgraph}()},
\code{\link{transitivity}()},
\code{\link{unfold_tree}()},
\code{\link{which_multiple}()},
\code{\link{which_mutual}()}
}
\author{
Tamas Nepusz \email{ntamas@gmail.com} and Gabor Csardi
\email{csardi.gabor@gmail.com} for the R interface
}
\concept{structural.properties}
\keyword{graphs}
|