Remarks
Definitions
- Cycle – An edge path with nodes
n0, n1, n2, ... , nkforms a cycle ifn0 = nkand consists of at least one edge. - Acyclic graph – A graph that contains no directed cycle.
- Cyclic graph – A graph that contains a directed cycle.
- Connected graph – A graph in which there exists an undirected path of edges between every pair of nodes.
- Strongly connected graph – A graph in which there exists a directed path between each pair of nodes.
- Biconnected graph – A graph that has no cut vertex or articulation point (i.e., a node whose removal disconnects the graph).
- Bipartite graph – A graph whose nodes can be partitioned into two sets such that each edge connects two nodes of different sets.
- Tree – A acyclic graph, in which any pair of nodes is connected through a path. If one node of a tree is distinguished from the other nodes, then the tree is called rooted tree.
- N-ary tree – A directed rooted tree where each node has a maximum of
nchildren. - Forest – A graph whose connected components are trees.
- Simple graph – An undirected graph that contains no self-loops or multi-edges.
- Planar graph – A graph that can be drawn on the plane without edge crossings.
- Multi-Edges – Multi-edges are edges that are incident to the same two nodes.
subgraphNodes and subgraphEdges can be used to run the analysis on an induced subgraph, only. Note that the subgraph will be reevaluated for each analysis.
Examples
const analyzer = new GraphStructureAnalyzer(graph)See Also
Developer's Guide
Members
Constructors
Properties
Gets or sets the collection of edges which define an induced subgraph for the algorithms to work on.
If nothing is set, all edges of the graph will be considered.
If only the excludes are set, all edges in the graph except those provided in the excludes are processed.
Note that edges which start or end at nodes that are not in the subgraphNodes are automatically not considered by the algorithms.
ItemCollection<T> instances may be shared among algorithm instances and will be (re-)evaluated upon (re-)execution of the algorithms.
Examples
const isConnectedViaBlueEdges = new GraphStructureAnalyzer({
graph,
subgraphEdges: {
delegate: (edge) =>
edge.style instanceof PolylineEdgeStyle &&
edge.style.stroke === Stroke.BLUE,
},
}).isConnected()Gets or sets the collection of nodes which define an induced subgraph for the algorithms to work on.
If nothing is set, all nodes of the graph will be considered.
If only the excludes are set, all nodes in the graph except those provided in the excludes are processed.
ItemCollection<T> instances may be shared among algorithm instances and will be (re-)evaluated upon (re-)execution of the algorithms.
Examples
const averageDegreeOfLabeledSubgraph = new GraphStructureAnalyzer({
graph,
subgraphNodes: { delegate: (node) => node.labels.size > 0 },
}).getAverageDegree()algorithm.subgraphNodes = graphComponent.selection.nodesalgorithm.subgraphNodes.excludes = (n) => graph.isGroupNode(n)algorithm.subgraphNodes = graphComponent.selection.nodes
algorithm.subgraphNodes.excludes = (n) => graph.isGroupNode(n)Methods
|E| / |V|for directed graphs2 * |E| / |V|for undirected graphs
Parameters
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- number
- The average degree of the given graph.
Complexity
O(1), O(|V| + |E|) when subgraph filtering is enabled.edge_weight_sum / |V|for directed graphs2 * edge_weight_sum / |V|for undirected graphs
Parameters
- edgeWeights: IMapper<IEdge, number>
- The mapping that provides the weights of the edges.
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- number
- The average weighted degree of the given graph
Complexity
O(|E|), O(|V| + |E|) when subgraph filtering is enabled|E| / (|N| * (|N| - 1))for directed simple graphs2 * |E| / (|N| * (|N| - 1))for undirected simple graphs
Parameters
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- number
- The density of the given graph.
Parameters
- edgeCosts: IMapper<IEdge, number>
- The mapping that provides the costs of the edges.
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- number
- The diameter of the given graph.
Determines the multi-edges of the directed or undirected graph.
Parameters
- directed?: boolean
- Whether to respect the direction of the edges.
Return Value
- IEnumerable<IEnumerable<IEdge>>
- A collection of multi-edges.
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge-to-edge connections.
Complexity
Determines the multi-edges adjacent to the given node of the directed or undirected graph.
Parameters
- node: INode
- The node that is adjacent to the multi-edges to determine.
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- IEnumerable<IEnumerable<IEdge>>
- A collection of multi-edges.
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge-to-edge connections.
Determines the multi-edges between the source and target node of the given edge of the directed or undirected graph.
Parameters
- edge: IEdge
- The edge with the same source and target as the edges to determine.
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- IEnumerable<IEdge>
- The multi-edges.
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge-to-edge connections.
Gets the nodes of the graph in topological order.
Return Value
- IEnumerable<INode>
- The nodes of the graph in topological order.
Complexity
Parameters
- directed?: boolean
- Whether to respect the direction of the edges.
Return Value
- boolean
trueif the graph contains multi-edges,falseotherwise
Examples
const isMultipleEdgeFree = new GraphStructureAnalyzer(graph).isSimple()Sample Graphs
Return Value
- boolean
trueif the graph contains self-loops,falseotherwise
Examples
const hasSelfLoops = new GraphStructureAnalyzer(graph).hasSelfLoops()Parameters
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- boolean
trueif the graph is acyclic,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isAcyclic = new GraphStructureAnalyzer(graph).isAcyclic(true)Sample Graphs
See Also
API
- isCyclic
Return Value
- boolean
trueif the graph is biconnected,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isBiconnected = new GraphStructureAnalyzer(graph).isBiconnected()Sample Graphs
Return Value
- boolean
trueif the graph is bipartite,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isBipartite = new GraphStructureAnalyzer(graph).isBipartite()Sample Graphs
Return Value
- boolean
trueif the graph is connected,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isConnected = new GraphStructureAnalyzer(graph).isConnected()Sample Graphs
Parameters
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- boolean
trueif the graph is cyclic,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isCyclic = new GraphStructureAnalyzer(graph).isCyclic(true)Sample Graphs
See Also
API
- isAcyclic
Parameters
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- boolean
trueif the graph is a forest,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge-to-edge connections.
Examples
const isForest = new GraphStructureAnalyzer(graph).isForest(true)Sample Graphs
See Also
Developer's Guide
Parameters
- maxChildCount: number
- The maximum number of children allowed per node in the tree.
Return Value
- boolean
trueif the graph is a directed rooted tree where each node has at mostmaxChildCountchildren,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isNaryTree = new GraphStructureAnalyzer(graph).isNaryTree(3)Sample Graphs
3 childrenSee Also
Developer's Guide
Return Value
- boolean
trueif the graph is planar,falseotherwise.
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isPlanar = new GraphStructureAnalyzer(graph).isPlanar()Sample Graphs
An undirected graph is called simple if there are no two edges that connect the same nodes as well as no self-loops.
Since an IGraph can have edges ending at other edges, a graph containing those constructs will also not be simple.
Return Value
- boolean
trueif the graph is simple,falseotherwise
Examples
const isSimple = new GraphStructureAnalyzer(graph).isSimple()Sample Graphs
Return Value
- boolean
trueif the graph is strongly connected,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isStronglyConnected = new GraphStructureAnalyzer(
graph,
).isStronglyConnected()Sample Graphs
Parameters
- directed?: boolean
- Whether or not to respect the direction of the edges.
Return Value
- boolean
trueif the graph is a tree,falseotherwise
Throws
- Exception ({ name: 'InvalidOperationError' })
- If the graph has edge to edge connections.
Examples
const isTree = new GraphStructureAnalyzer(graph).isTree(false)Sample Graphs
See Also
Developer's Guide