Improve README
Opened this issue · 1 comments
brenolf commented
The README of the repo is not nearly comprehensive. There should be examples and API explanations.
pashute commented
Taking examples from your grapho.test.js
We will create a Graph object with two vertices.
The Grapho Graph object has a member V which holds all the vertices defined in it.
let G = new Grapho() // G.V.size == 0
The Grapho. vertex() method adds vertices to the graph. It has an optional parameter for the Vertex object that will be added to the graph. Without parameters, it adds a default vertex. The vertex index is undefined until a traversal algorithm was used with the graph.
let v1 = G.vertex() // adds a default automatically created vertex
// G.V.size == 1.
// v1.index is undefined
let v2 = new Vertex()
G.vertex(v2)
// G.V.size ==2
// v2.index is undefined.
The find(source, target, algorithm) method finds the target vertex connected to the source target using the chosen algorithm.
let bfsV1toV2 = G.find(v1, v2, 'bfs') // using the BFS algorithm
let defaultV1toV2 = G.find(v1, v2) // using the default (DFS) algorithm
let findAll = G.find(v1) // finds all indices from v1, using the default algorithm
// calling without parameters throws an invalid-type error.
// calling with an unknown algorithm name throws an invalid reference error.