new Graph()
A class to represent a abstract graph.
Properties:
| Name | Type | Description |
|---|---|---|
vertexes |
Array | All nodes in this graph. |
edges |
Array | Connectors in this graph. |
- Source:
Extends
- ObjectEx
Methods
-
addEdge(edge, vertex1, vertex2)
-
Add an edge to graph and connect it to vertex1 and vertex2.
Parameters:
Name Type Description edgeKekule.GraphEdge vertex1Kekule.GraphVertex vertex2Kekule.GraphVertex - Source:
-
addVertex(vertex)
-
Add a new vertex to graph.
Parameters:
Name Type Description vertexKekule.GraphVertex - Source:
-
newEdge(vertex1, vertex2) → {Kekule.GraphEdge}
-
Create a new edge in graph and connect it to vertex1 and vertex2.
Parameters:
Name Type Description vertex1Kekule.GraphVertex vertex2Kekule.GraphVertex - Source:
Returns:
- Type
- Kekule.GraphEdge
-
newVertex() → {Kekule.GraphVertex}
-
Create a new vertex in graph.
- Source:
Returns:
- Type
- Kekule.GraphVertex
-
removeEdge(edge)
-
Remove an edge from graph.
Parameters:
Name Type Description edgeKekule.GraphEdge - Source:
-
removeVertex(vertex)
-
Remove a vertex (and its connected edges) from graph.
Parameters:
Name Type Description vertexKekule.GraphVertex - Source:
-
traverse(callback, startingVertex, mode) → {Array}
-
Traverse the whole graph. Each vertex or edge traversed will be passed in callback function.
Parameters:
Name Type Description callbackFunc Callback(currObj, isEdge). startingVertexKekule.GraphVertex If not set, first vertex of graph will be used as starting point. modeInt Traverse mode, depth or breadth first, value from Kekule.GraphTraverseMode. - Source:
Returns:
Items are hash object containing the following fields: { vertexes: Array, edges: Array } which stores the traverse sequence. As the graph may not be a connected one, so several sequence may be returned.- Type
- Array