Source Code
By: ThorstenSeitz
License: Eclipse Public License - v 1.0
Packages
graph
graph.directed
graph.explicit
graph.filter
graph.implicit
graph.multigraph
graph.traversal
graph.traversal.iterator
graph.traversal.propagator
graph.traversal.visitor
graph.undirected
Dependencies
ceylon.collection1.1.0
common0.0.1
By: ThorstenSeitz
Interfaces
AdjacencyGraphSource Codeshared AdjacencyGraph<V>
given V satisfies Object

Concept

An AdjacencyGraph is a graph which is concerned only with the vertices and not with the edges. There are no explicit edge objects, adjacent vertices are simply accessed as AdjacencyGraph.neighbors(). For many use cases this is sufficient.

Complexity

Infinite Graphs

The number of vertices may be infinite in which case the user has to take care not to call methods which will not return (this is similar to an Iterable which may contain an infinite number of elements).

The same applies for the number of neighbors of a vertex.

Design Notes

Think about making Vertex (and, in subclasses, Edge) member classes! cf. Graph example here

EdgeSource Codeshared Edge<Vertex,E>
given Vertex satisfies Object
given E satisfies Edge<Vertex,E>

A generic edge between two vertices of type Vertex.

ImplicitEdgeWeightsSource Codeshared ImplicitEdgeWeights<Weight,Vertex>
given Weight satisfies Summable<Weight>

ImplicitEdgeWeights gives a mapping from vertex pairs to weights and a zero element to make Weight a monoid.

IncidenceGraphSource Codeshared IncidenceGraph<V,E>
given V satisfies Object
given E satisfies Edge<V,E>

A graph with explicit edges.

The number of vertices and edges may be infinite in which case the user has to take care not to call methods which will not return (this is similar to an Iterable which may contain an infinite number of elements).

The same applies for the neighbors or adjacent edges of a vertex.

SimpleGraphSource Codeshared SimpleGraph<V,E>
given V satisfies Object
given E satisfies Edge<V,E>

A SimpleGraph contains at most one undirected or two directed (but opposite) edges between any two vertices.

VertexListSource Codeshared VertexList<V>
given V satisfies Object

A Graph with efficient access to all vertices.

Complexity

  • VertexList.vertices is required to be constant time; iterating over the iterable is required to be linear in the number of vertices
WalkSource Codeshared Walk<V,E>
given V satisfies Object
given E satisfies Edge<V,E>

A Walk is a possibly empty sequence of edges connecting two vertices.

WeightsSource Codeshared Weights<Weight,Vertex,E>
given Weight satisfies Summable<Weight>
given Vertex satisfies Object
given E satisfies Edge<Vertex,E>

Weights gives a mapping from edges to weights and a zero element to make Weight a monoid.

Classes
HopsSource Codeshared Hops<V,E>
given V satisfies Object
given E satisfies Edge<V,E>

Hops assigns an edge the weight of 1 and can therefore be used to count the number of edges, or 'hops' between two vertices.