Type of the vertices of this graph.
Type of the data associated with edges.
Creates a new graph adapter with the given options.
Type of the vertices of this graph.
Type of the data associated with edges.
Options for configuring this instance.
Generated using TypeDoc
Generic graph data structure that supports all types of vertex objects by using
Map
s. Allows you to associate arbitrary data with each edge. For vertex data, use an appropriateTVertex
type.// Type of the data we want to use as vertices. interface Vertex { id: number; name: string; // ... } // Create a new graph. const graph = GenericGraphAdapter.create<Vertex, string>(); // Add some vertices and edges. const v1 = {id: 1, name: "foo"}; const v2 = {id: 2, name: "bar"}; const v3 = {id: 2, name: "bar"}; graph.addVertex(v1); graph.addVertex(v2); graph.addVertex(v3); graph.addEdge(v1, v2, "This is edge 1-2."); graph.addEdge(v2, v3, "This is edge 2-3."); // Fetch the data associated with the edge. graph.getEdgeData(v1, v2); // => "This is edge 1-2." // This edge would create cycle. graph.addEdge(v3, v1) // => false graph.hasEdge(v3, v1) // => false
CommonAdapter