Accessing Graph Properties
The following is an overview of functions for accessing graph properties. For functions that modify graphs, see Making and Modifying Graphs.
Graph Properties:
-
nv: Returns number of vertices in graph. -
ne: Returns number of edges in graph. -
vertices: Iterable object of all graph vertices. -
edges: Iterable object of all graph edges. -
has_vertex: Checks for whether graph includes a vertex. -
has_edge(g, s, d): Checks for whether graph includes an edge from a given sourcesto a given destinationd. -
has_edge(g, e)will return true if there is an edge in g that satisfiese == ffor anyf ∈ edges(g). This is a strict equality test that may require all properties ofeare the same. This definition of equality depends on the implementation. For testing whether an edge exists between two verticess,dusehas_edge(g, s, d).
to use the has_edge(g, e) method safely, it is important to understand the conditions under which edges are equal to each other. These conditions are defined by the has_edge(g::G,e) method as defined by the graph type G. The default behavior is to check has_edge(g,src(e),dst(e)). This distinction exists to allow new graph types such as MetaGraphs or MultiGraphs to distinguish between edges with the same source and destination but potentially different properties.
|
-
has_self_loopsChecks for self-loops. -
is_directedChecks if graph is directed. -
eltypeReturns element type of graphs.
Vertex Properties
-
neighbors: Return array of neighbors of a vertex. If graph is directed, output is equivalent ofoutneighbors. -
all_neighbors: Returns array of all neighbors (bothinneighborsandoutneighbors). For undirected graphs, equivalent toneighbors. -
inneighbors: Return array of in-neighbors. Equivalent toneighborsfor undirected graphs. -
outneighbors: Return array of out-neighbors. Equivalent toneighborsfor undirected graphs.