Appearance
Ogma.algorithms
Algorithms namespace of Ogma, everything to calculate metrics and run analysis on the graph.
ogma.algorithms.betweenness([options])
Returns the betweenness score for the given nodes
Arguments
- options(optional)
BetweennessOptions
ogma.algorithms.bfs(options)
Breadth first search.
Arguments
- options
TraversalOptions
ogma.algorithms.circlePack(options)
Arguments
- options
object
- duration(optional)
number
[=0]
Animation duration - easing(optional)
Easing
[='linear']
Animation easing - margin(optional)
number
[=0]
Margin between nodes - nodes
NodeList
Nodes to pack - origin(optional)
Point
[={x: 0, y: 0}]
Origin of the circle pack - sort(optional)
function(a: Node, b: Node): number | 'asc' | 'desc'
Sorting comparator function or 'asc' or 'desc' to sort by radius in ascending or descending order from the center
- duration(optional)
Returns
-
Promise<NodeList>
A promise resolving to the nodes with their new positions.
ogma.algorithms.detectCycle([options])
Returns the first cycle found as a NodeList.
Arguments
- options(optional)
object
Returns
-
NodeList|null
ogma.algorithms.dfs(options)
Depth first search.
Arguments
- options
TraversalOptions
ogma.algorithms.getAllSimpleCycles([options])
Implements Tarjan's algorithm of finding all simple cycles in the directed graph.
Arguments
- options(optional)
object
Returns
-
Array<NodeList>
ogma.algorithms.getMinimumEnclosingCircle(nodes)
Calculates the minimum enclosing circle for the given nodes. It will throw an error if no nodes are provided.
Arguments
- nodes
NodeList
Returns
-
{ x: number, y: number, radius: number }
The center and radius of the circle.
ogma.algorithms.hasCycle([options])
Checks whether the given graph has cycles in it.
Arguments
- options(optional)
object
Returns
-
Boolean
ogma.algorithms.minimumSpanningTree([nodes][, edges][, edgeCostFunction])
Kruskal's minimum-spanning-tree algorithm. It finds the edge set for the graph of the least possible edge cost that connects all the nodes of the graph.
Arguments
- nodes(optional)
NodeList
Nodes of the subgraph to analyze. By default uses all the visible nodes. - edges(optional)
EdgeList
Edges of the subgraph to analyze. By default all the visible edges. - edgeCostFunction(optional)
function(edge: Edge):number
Function to get the weight of the edge, for instance it can take it from the data fields.
Returns
ogma.algorithms.shortestPath(options)
Compute the shortest path between the specified source and target nodes.
Arguments
- options
object
- directed(optional)
boolean
[=false]
Indicates if the graph should be considered as directed. - edgeCostFunction(optional)
function(edge: Edge): number
Function retrieving the cost of an edge. By default, returns 1 for all edges. - edges(optional)
EdgeList
[=undefined]
Indicates on which elements to perform the algorithm. If not specified, allow all visible edges. - heuristicFunction(optional)
function(source: Node, target: Node): number
Function retrieving an estimation of the distance between two nodes. By default no heuristic is used. - nodes(optional)
NodeList
[=undefined]
Indicates on which elements to perform the algorithm. If not specified, allow all visible nodes. - source
Node|NodeId
- target
Node|NodeId
- directed(optional)
Returns