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 graphg
includes a vertex numberedv
.has_edge(g, s, d)
checks whether graphg
includes an edge from the source vertexs
to the destination vertexd
.has_edge(g, e)
returns true if there is an edge in g that satisfiese == f
for anyf ∈ edges(g)
. This is a strict equality test that may require all properties ofe
are the same. This definition of equality depends on the implementation. For testing whether an edge exists between two verticess,d
usehas_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 ifg
is a directed graph.eltype(g)
returns the type of the vertices ofg
.
Vertex properties
neighbors(g, v)
returns the neighbors of vertexv
in an iterable (ifg
is directed, only outneighbors are returned).all_neighbors(
returns all the neighbors of vertexv
(ifg
is directed, both inneighbors and outneighbors are returned).inneighbors
return the inneighbors of vertexv
(equivalent toneighbors
for undirected graphs).outneighbors
returns the outneighbors of vertexv
(equivalent toneighbors
for undirected graphs).
Edge properties
src(e)
gives the source vertexs
of an edge(s, d)
.dst(e)
gives the destination vertexd
of an edge(s, d)
.reverse(e)
creates a new edge(d, s)
from edge(s, d)
.