# What is the matter with EdgeList[] of a directed graph?

Given:

dag1 = {"scst" \[DirectedEdge] "stel", "scst" \[DirectedEdge] "sfin",
"scst" \[DirectedEdge] "sbus", "scst" \[DirectedEdge] "swhl",
"scst" \[DirectedEdge] "ma6", "sfin" \[DirectedEdge] "stel",
"sfin" \[DirectedEdge] "sbus", "sfin" \[DirectedEdge] "swhl",
"sbus" \[DirectedEdge] "stel", "sbus" \[DirectedEdge] "ma6",
"swhl" \[DirectedEdge] "sbus", "swhl" \[DirectedEdge] "ma6"};


The following code intends to extract all the edges directed towards the vertex "sfin". However, it gives an empty set!

EdgeList[dag1, _ -> "sfin"]


Given a directed graph dag1, I like to extract the set of vertices having directed edges towards vertex "sfin", such as

{"sfin", "scst"}       for vertex "sfin"
{"bus", "stel", "ma6"} for vertex "sbus", etc.


Note that the vertex of interest is the first element in the above two example sets.

Inside EdgeList you must use DirectedEdge instead of Rule
EdgeList[dag1, _ \[DirectedEdge] "sfin"]

EdgeList[dag1, _ \[DirectedEdge] "sfin" | "sfin" \[DirectedEdge] _]

• @halmir: VertexIn/Out components give a different result. I simply like to get the list of vertices having directed In links to a given vertex. Since the graph given dag1 is a layered DAG, the result should be a list of vertices (acting as inputs) to a given vertex. I want to write the DAG as a set of functions, such as "sfin"=f["scst"] or "swhl"=f["scst", "sfin"] etc. Commented Nov 6, 2023 at 21:06