Graph access
The following is an overview of functions for accessing graph properties.
Global graph properties
nv(g)returns the number of vertices ing.ne(g)returns the number of edges ing.vertices(g)returns an iterable object containing all the vertices ing.edges(g)returns an iterable object containing all the edges ing.has_vertex(g, v)checks whether graphgincludes a vertex numberedv.has_edge(g, s, d)checks whether graphgincludes an edge from the source vertexsto the destination vertexd.has_edge(g, e)returns 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). Note: to use thehas_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 thehas_edge(g::G,e)method as defined by the graph typeG. The default behavior is to checkhas_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_loops(g)checks for self-loops ing.is_directed(g)checks ifgis a directed graph.eltype(g)returns the type of the vertices ofg.
Vertex properties
neighbors(g, v)returns the neighbors of vertexvin an iterable (ifgis directed, only outneighbors are returned).all_neighbors(returns all the neighbors of vertexv(ifgis directed, both inneighbors and outneighbors are returned).inneighborsreturn the inneighbors of vertexv(equivalent toneighborsfor undirected graphs).outneighborsreturns the outneighbors of vertexv(equivalent toneighborsfor undirected graphs).
Edge properties
src(e)gives the source vertexsof an edge(s, d).dst(e)gives the destination vertexdof an edge(s, d).reverse(e)creates a new edge(d, s)from edge(s, d).