layout | title | nav_order | menu_toc | |||||||
---|---|---|---|---|---|---|---|---|---|---|
default |
Properties |
4 |
|
All the following properties are read-only and may not be changed by the user.
Number of nodes in the graph.
Example
const graph = new Graph();
graph.addNode('John');
graph.addNode('Jack');
graph.order;
>>> 2
Number of edges in the graph.
Example
const graph = new Graph();
graph.addNode('John');
graph.addNode('Jack');
graph.addEdge('John', 'Jack');
graph.size;
>>> 1
Variants
#.directedSize
#.undirectedSize
Type of the graph. One of mixed
, directed
or undirected
.
Example
const graph = new Graph();
graph.type;
>>> 'mixed'
const directedGraph = new DirectedGraph();
directedGraph.type;
>>> 'directed'
Whether the graph accepts parallel edges or not.
Example
const graph = new Graph();
graph.multi;
>>> false
const multiGraph = new MultiGraph();
multiGraph.multi;
>>> true
Whether the graph accepts self loops or not.
const graph = new Graph();
graph.allowSelfLoops;
>>> true
const otherGraph = new Graph({allowSelfLoops: false});
graph.allowSelfLoops;
>>> false
The total number of self loop included in the graph.
const graph = new Graph();
graph.selfLoopCount
>>> 0
graph.mergeEdge('John', 'John');
graph.selfLoopCount
>>> 1
Variants
#.directedSelfLoopCount
#.undirectedSelfLoopCount
A string containing the graph instance's implementation name.
import Graph from 'graphology';
const graph = new Graph();
graph.implementation;
>>> 'graphology'
It can be useful if you ever need to optimize libraries based upon the knowledge that the given instance is from a specific implementation.