This package provides several graph types that implement different subsets of interfaces. In particular, it has three graph types:
All of these types of parametric types. One can easily derive customized graph types using different type parameters.
GenericAdjacencyList implements the adjacency list representation of a graph, where each vertex maintains a list of neighbors (i.e. adjacent vertices).
Here is the definition of GenericAdjacencyList:
type GenericAdjacencyList{V, VList, AdjList} <: AbstractGraph{V, Edge{V}}
It has three type parameters:
The package defines following aliases for convenience:
typealias SimpleAdjacencyList GenericAdjacencyList{Int, Range1{Int}, Vector{Vector{Int}}}
typealias AdjacencyList{V} GenericAdjacencyList{V, Vector{V}, Vector{Vector{V}}}
GenericAdjacencyList implements the following interfaces
Specially, it implements the following methods:
returns whether g is a directed graph.
returns the number of vertices contained in g.
returns an iterable view/container of all vertices.
returns the number of edges contained in g.
returns the index of a vertex v in graph g
returns the number of outgoing neighbors from vertex v in graph g.
returns an iterable view/container of all outgoing neighbors of vertex v in graph g.
In addition, it implements following methods for construction:
constructs a simple adjacency list with nv vertices and no edges (initially).
constructs an empty adjacency list of vertex type V.
adds a vertex v. This function applies only to graph of type AdjacencyList. It returns the added vertex.
If the vertex type is KeyVertex{K}, then the second argument here can be the key value, and the function will constructs a vertex and assigns an index.
adds an edge between u and v, such that v becomes an outgoing neighbor of u. If g is undirected, then u is also added to the neighbor list of v.
GenericIncidenceList implements the incidence list representation of a graph, where each vertex maintains a list of outgoing edges.
Here is the definition of GenericIncidenceList:
type GenericIncidenceList{V, E, VList, IncList} <: AbstractGraph{V, E}
It has four type parameters:
The package defines following aliases for convenience:
typealias SimpleIncidenceList GenericIncidenceList{Int, IEdge, Range1{Int}, Vector{Vector{IEdge}}}
typealias IncidenceList{V} GenericIncidenceList{V, Edge{V}, Vector{V}, Vector{Vector{Edge{V}}}}
GenericIncidenceList implements the following interfaces:
Specially, it implements the following methods:
returns whether g is a directed graph.
returns the number of vertices contained in g.
returns an iterable view/container of all vertices.
returns the number of edges contained in g.
returns the index of a vertex v in graph g
returns the index of a vertex e in graph g.
returns the source vertex of an edge e in graph g.
returns the target vertex of an edge e in graph g.
returns the number of outgoing neighbors from vertex v in graph g.
returns the number of outgoing edges from vertex v in graph g.
returns an iterable view/container of all outgoing neighbors of vertex v in graph g.
Note: out_neighbors here is implemented based on out_edges via a proxy type. Therefore, it may be less efficient than the counterpart for GenericAdjacencyList.
In addition, it implements following methods for construction:
constructs a simple incidence list with nv vertices and no edges (initially).
constructs an empty incidence list of vertex type V. The edge type is Edge{V}.
adds a vertex v. This function applies only to graph of type AdjacencyList. It returns the added vertex.
If the vertex type is KeyVertex{K}, then the second argument here can be the key value, and the function will constructs a vertex and assigns an index.
adds an edge between u and v, such that v becomes an outgoing neighbor of u. If g is undirected, then u is also added to the neighbor list of v. It returns the added edge.
GenericGraph provides a complete interface by integrating edge list, adjacency list, and incidence list into one type. The definition is given by
type GenericGraph{V,E,VList,EList,AdjList,IncList} <: AbstractGraph{V,E}
It has six type parameters:
It also defines SimpleGraph as follows
typealias SimpleGraph GenericGraph{
Int, # V
IEdge, # E
Range1{Int}, # VList
Vector{IEdge}, # EList
Vector{Vector{Int}}, # AdjList
Vector{Vector{IEdge}}} # IncList
GenericGraph implements the following interfaces:
Specifically, it implements the following methods:
returns whether g is a directed graph.
returns the number of vertices contained in g.
returns an iterable view/container of all vertices.
returns the number of edges contained in g.
returns an iterable view/container of all edges.
returns the index of a vertex v in graph g
returns the index of a vertex e in graph g.
returns the source vertex of an edge e in graph g.
returns the target vertex of an edge e in graph g.
returns the number of outgoing neighbors from vertex v in graph g.
returns the number of outgoing edges from vertex v in graph g.
returns an iterable view/container of all outgoing neighbors of vertex v in graph g.
In addition, it also implements the following methods for construction:
constructs an instance of SimpleGraph with nv vertices and no edges (initially).
constructs an empty graph of vertex type V and edge type E. The vertex list, edge list, adjacency list, and incidence list are respectively of types: Vector{V}, Vector{E}, Vector{Vector{V}}, and Vector{Vector{E}}.
adds a vertex v. v can also be a key value if V is KeyVertex, or a label string if V is ExVertex.
adds an edge e.
adds an edge between u and v. This applies only when E is either Edge or ExEdge.