An ordinary directed graph, using Hash.
DirectedHashGraph.new([vertices[, edges, [params]]])
Creates a directed graph, which has vertices and edges.
Specify vertex Array for vertices. (e.g. [0, 1, 2, 3]) Any object comparable using Object#eql? can be a vertex.
Specify edge Array for edges. (e.g. [[0, 1, 1.0], [2, 3, 2.0]]) Each edge consists of Array [source, target, weight]. The weight is optional.
The vertices and edges can be added later using add_vertex
, add_edge
.
params is a Hash specifying the return value of Graph#parameter. Rarely used.
Common methods for graph classes are described at Graph, GraphAlgorithm. See them.
self[ v, w ] = weight
Sets the weight of edge [v, w]
to weight.
Adds edge [v, w]
if not exists.
add_edge(v, w[, weight])
self[v, w]= weight
.
weight is set to 1
if omitted.delete_edge(v, w)
[v, w]
.add_vertex(v)
delete_vertex(v)
Deletes vertex v.
Also deletes the edges whose source/target vertex is v.