I have a simple tree graph with directed edges:
In: AdjacencyList[Graph[{a -> b, a -> c, b -> d, b -> e}], b]
Out: {a, d, e}
I wonder how I can select only the outgoing edge vertices elegantly.
{d, e}
In other words: I want the children of a vertex only.
The obvious solution for a tree is to always drop the first vertex. Sadly this approach fails for the root vertex, so there has to be some If
-branching - which I want to avoid.
So far I tried VertexOutComponent
and IncidenceList
but non of them seems to give the option to filter by edge direction.
Do you see an elegant approach there, or will I have to keep using root checks?
g = Graph[{a -> b, a -> c, b -> d, b -> e}];
you can doLast /@ EdgeList[g, b \[DirectedEdge] _]
. $\endgroup$VertexOutComponent
? "but non of them seems to give the option to filter by edge direction" $\leftarrow$ actually it does, that's why it has "Out" in the name. $\endgroup$AdjacencyList
for a directed graph include only vertices that are adjacent to the vertex, not also those it is adjacent from. Wouldn't that be more standard? (E.g., xlinux.nist.gov/dads/HTML/adjacencyListRep.html) Somewhat similarly for theVertexOutComponent
: why does the result for a vertex include that vertex when there is no self loop? Is there a standard reference that justifies this vocabulary? $\endgroup$