This class provides methods that check structural properties of a given graph.
Remarks
Note: Methods of this class work with instances of Graph. To analyze structural properties of IGraph instances use GraphStructureAnalyzer instead.
Definitions
- Cycle: An edge path with vertices
v0, v1, v2, ... , vk
forms a cycle ifv0 = vk
and 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 graph: An acyclic graph, in which any pair of vertices is connected through a path. If one vertex of a tree is distinguished from the other vertices, then the tree is called rooted tree.
- N-ary tree graph: A directed rooted tree where each node has a maximum of
n
children. - Forest graph: A graph whose connected components are trees.
- Simple graph: A graph that contains no self-loops and parallel edges.
- Planar graph: A graph that can be drawn on the plane without edge crossings.
- Average degree: The number of edges in comparison to the number of nodes.
- Average weighted degree: The sum of the edge weights in comparison to the number of nodes.
- Diameter:The maximum eccentricity of any vertex in the graph i.e., the length of the longest shortest path between any two vertices.
- Density: The ratio of edges of the graph to the maximum possible number of edges.
Type Details
- yfiles module
- algorithms
- yfiles-umd modules
- All layout modules, view-layout-bridge
- Legacy UMD name
- yfiles.algorithms.GraphChecker
Static Methods
Computes the average degree of a given graph.
Remarks
graph.E() / graph.N()
for directed graphs2 * graph.E() / graph.N()
for undirected graphs
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
- directed - boolean
true
if the graph should be considered as directed,false
otherwise
Returns
- ↪number
- the average degree of the given graph
Computes the average weighted degree of a given graph.
Remarks
edge_weight_sum / graph.N()
for directed graphs2 * edge_weight_sum / graph.N()
for undirected graphs
Complexity
O(graph.E())
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
- directed - boolean
true
if the graph should be considered as directed,false
otherwise- edgeWeight - IDataProvider
- IDataProvider that provides the weights of the edges
Domain Edge Values number the weight of an edge
Returns
- ↪number
- the average weighted degree of the given graph
Computes the density of a given simple graph.
Remarks
graph.E() / (graph.N() * (graph.N() - 1))
for directed simple graphs2 * graph.E() / (graph.N() * (graph.N() - 1))
for undirected simple graphs
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
- directed - boolean
true
if the graph should be considered as directed,false
otherwise
Returns
- ↪number
- the density of the given graph
Computes the diameter of a given graph.
Remarks
Parameters
A map of options to pass to the method.
- graph - Graph
- the input graph
- directed - boolean
true
if the graph should be considered as directed,false
otherwise- edgeCost - IDataProvider
- IDataProvider that provides the costs of the edges
Domain Edge Values number the cost of an edge
Returns
- ↪number
- the diameter of the given graph
Checks whether or not the given directed graph is acyclic.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is acyclic use isAcyclic instead.
A graph is called acyclic if it contains no directed cycle.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph is acyclic,false
, otherwise
Sample Graphs
isAcyclic(graph) <=> !isCyclic(graph)
.Checks whether or not the given undirected graph is biconnected.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is biconnected use isBiconnected instead.
A graph is called biconnected if it has no cut vertex or articulation point, i.e., no node whose removal disconnects the graph.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given undirected graph
Returns
- ↪boolean
true
if the graph is biconnected,false
otherwise
Sample Graphs
Checks whether or not the given undirected graph is bipartite.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is bipartite use isAcyclic instead.
A graph is called bipartite if its nodes can be partitioned into two sets such that each edge connects two nodes of different sets.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given undirected graph
Returns
- ↪boolean
true
if the graph is bipartite,false
otherwise
Sample Graphs
Checks whether or not the given graph is connected.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is connected use isConnected instead.
A graph is called connected if there exists an undirected path of edges between every pair of nodes.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph is connected,false
otherwise
Sample Graphs
Checks whether or not the given directed graph is cyclic.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is cyclic use isCyclic instead.
A graph is called cyclic if it contains a directed cycle.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph is cyclic,false
, otherwise
Sample Graphs
isCyclic(graph) <=> !isAcyclic(graph)
.Checks whether the given graph is a forest.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is a forest use isForest instead.
A graph is a forest if its connected components are trees.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph is a forest,false
otherwise
Sample Graphs
Checks whether or not the given undirected graph contains no multiple edges.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph has multiple edges use hasMultipleEdges instead.
The method returns true
if the graph contains no two distinct edges e1, e2
that connect the same pairs of nodes in either direction.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given undirected graph
Returns
- ↪boolean
true
if the graph contains no multiple edges,false
otherwise
Sample Graphs
isMultipleEdgeFree(graph) => isSimple(graph)
.Checks whether or not the given graph is a directed rooted tree where each node has a maximum of n
children.
Remarks
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
- n - number
Returns
- ↪boolean
true
if the graph is a directed rooted tree where each node has at mostn
children,false
otherwise
Sample Graphs
Checks whether or not the given directed graph is a directed rooted tree.
Remarks
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph is a directed rooted tree,false
otherwise
Sample Graphs
isRootedTree(graph) => isTree(graph)
Checks whether or not the given graph contains no self-loops.
Remarks
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph contains no self-loops,false
otherwise
!isSelfLoopFree(graph) => !isAcyclic(graph)
Checks whether or not the given directed graph is simple.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is simple use isAcyclic instead.
A graph is called simple if it contains no two distinct edges e1, e2
where e1.source() == e2.source() && e1.target() == e2.target()
.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given directed graph
Returns
- ↪boolean
true
if the graph is simple,false
otherwise
Sample Graphs
isMultipleEdgeFree(graph) => isSimple(graph)
.Checks whether or not the given directed graph is strongly connected.
Remarks
Note: This method works with instances of Graph. To determine whether an IGraph is strongly connected use isStronglyConnected instead.
A graph is called strongly connected if there exists a directed path between each pair of nodes.
Parameters
A map of options to pass to the method.
- graph - Graph
- the given directed graph
Returns
- ↪boolean
true
if the graph is strongly connected,false
, otherwise
Sample Graphs
Checks whether or not the given graph is an undirected tree.
Remarks
Parameters
A map of options to pass to the method.
- graph - Graph
- the given graph
Returns
- ↪boolean
true
if the graph is an undirected tree,false
otherwise
Sample Graphs
isRootedTree(graph) => isTree(graph)