C

StructureGraphAdapter

Converts an IGraph instance into a structure-only LayoutGraph instance that is created by createStructureGraph.
Inheritance Hierarchy

Remarks

This class creates a structural copy of a given IGraph and provides methods to convert items from one graph instance to their corresponding item in the other graph instance.

The main use case of this class is executing one of the analysis algorithms on an IGraph, for example shortestPath, findCycle, and graphCentrality. However, for most of the algorithms the analysis algorithms are preferred, as they can be used without any conversion directly on IGraph instances.

For executing a layout algorithm, LayoutExecutor would be preferred or one of the applyLayout and applyLayoutAnimated methods. LayoutGraphAdapter is the exact equivalent of this type for layout algorithms if low-level control over the conversion to LayoutGraph is needed.

Edge to edge connections are not supported. If the original IGraph contains such connections, an ArgumentError is thrown.

See Also

Developer's Guide

API

createStructureGraph, LayoutGraphAdapter, LayoutExecutor, LayoutGraphAlgorithms

Members

No filters for this type

Constructors

Initializes a new instance of the StructureGraphAdapter class.
This will create a copy of the originalGraph that has the same structure and makes it available via the structureGraph property.

Parameters

originalGraph: IGraph
The original graph whose structure will be copied.
subgraphNodes?: IEnumerable<INode>
The (sub) set of nodes to use to build the graph. If omitted, all nodes will be used. Providing nodes which are not part of the originalGraph will result in an exception.
subgraphEdges?: IEnumerable<IEdge>
The (sub) set of edges to use to build the graph. If omitted, all edges will be used. Providing edges which are not part of the originalGraph will result in an exception.

Throws

Exception ({ name: 'ArgumentError' })
If originalGraph contains edge to edge connections, or if subgraphNodes or subgraphEdges contain elements which are not contained in the originalGraph.

Properties

Gets the original graph instance.
readonlyfinal

Property Value

The original graph.
Gets the graph instance that is created during the constructor call.
readonlyfinal

Property Value

The graph instance that can be used for the algorithms.

Methods

Creates an IEnumerable<T> of copied LayoutEdge instances by mapping the provided original IEdge instances from the originalGraph to their corresponding originals in the structureGraph.
This method is particularly useful when algorithms yield IListEnumerable<IEdge> instances as results, and those results need to be interpreted in terms of the structureGraph rather than the originalGraph.
final

Parameters

edges: IEnumerable<IEdge>
A collection of original IEdge instances for which the corresponding copied LayoutEdge instances will be returned.

Return Value

IListEnumerable<LayoutEdge>
An IListEnumerable<Edge> that contains the copied LayoutEdge instances corresponding to the provided edges; if an edge has no copied counterpart, null is included in its place.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided edges collection is null.
Creates an IEnumerable<T> of copied LayoutNode instances by mapping the provided original INode instances from the originalGraph to their corresponding originals in the structureGraph.
This method is particularly useful when algorithms yield IListEnumerable<INode> instances as results, and those results need to be interpreted in terms of the structureGraph rather than the originalGraph.
final

Parameters

nodes: IEnumerable<INode>
A collection of original INode instances for which the corresponding copied LayoutNode instances will be returned.

Return Value

IListEnumerable<LayoutNode>
An IListEnumerable<Node> that contains the copied LayoutNode instances corresponding to the provided nodes; if a node has no copied counterpart, null is included in its place.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided nodes collection is null.
Creates an IMapper<K, V> that delegates its operations to the provided IMapper<K, V> for items within the context of the IGraph, but translates requests so they can be made using the corresponding original edges.
This method is useful when algorithms return IMapper<K, V> instances that operate on copied edges, but the values should be queried or provided based on the corresponding original edges from the originalGraph.
final

Parameters

mapper: IMapper<LayoutEdge, TValue>
The edge-to-value map that will be used for resolving values based on copied edges.

Return Value

IMapper<IEdge, TValue>
An IMapper<INode, T> that translates queries for original edges into queries for the corresponding copied edges in the provided mapper.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided mapper is null.
Creates an IMapper<K, V> that delegates its operations to the provided IMapper<K, V> for items within the context of the IGraph, but translates requests so they can be made using the corresponding original nodes.
This method is useful when algorithms return IMapper<K, V> instances that operate on copied nodes, but the values should be queried or provided based on the corresponding original nodes from the originalGraph.
final

Parameters

mapper: IMapper<LayoutNode, TValue>
The node-to-value map that will be used for resolving values based on copied nodes.

Return Value

IMapper<INode, TValue>
An IMapper<INode, T> that translates queries for original nodes into queries for the corresponding copied nodes in the provided mapper.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided mapper is null.
Creates an IEnumerable<T> of original IEdge instances by mapping the provided copied LayoutEdge instances from the structureGraph to their corresponding originals in the originalGraph.
This method is particularly useful when algorithms yield IListEnumerable<Edge> instances as results, and those results need to be interpreted in terms of the originalGraph rather than the structureGraph.
final

Parameters

edges: IEnumerable<LayoutEdge>
A collection of copied LayoutEdge instances for which the corresponding original IEdge instances will be returned.

Return Value

IListEnumerable<IEdge>
An IListEnumerable<IEdge> that contains the original IEdge instances corresponding to the provided edges; if an edge has no original counterpart, null is included in its place.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided edges collection is null.
Creates an IEnumerable<T> of original INode instances by mapping the provided copied LayoutNode instances from the structureGraph to their corresponding originals in the originalGraph.
This method is particularly useful when algorithms yield IListEnumerable<Node> instances as results, and those results need to be interpreted in terms of the originalGraph rather than the structureGraph.
final

Parameters

nodes: IEnumerable<LayoutNode>
A collection of copied LayoutNode instances for which the corresponding original INode instances will be returned.

Return Value

IListEnumerable<INode>
An IListEnumerable<INode> that contains the original INode instances corresponding to the provided nodes; if a node has no original counterpart, null is included in its place.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided nodes collection is null.
Creates an IMapper<K, V> that delegates its operations to the provided IMapper<K, V> for items within the context of the structureGraph, but translates requests so they can be made using the corresponding copied edges.
This method is useful when algorithms return IMapper<K, V> instances that operate on original edges, but the values should be queried or provided based on the corresponding copied edges from the structureGraph.
final

Parameters

mapper: IMapper<IEdge, TValue>
The edge-to-value map that will be used for resolving values based on original edges.

Return Value

IMapper<LayoutEdge, TValue>
An IMapper<INode, T> that translates queries for copied edges into queries for the corresponding original edges in the provided mapper.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided mapper is null.
Creates an IMapper<K, V> that delegates its operations to the provided IMapper<K, V> for items within the context of the structureGraph, but translates requests so they can be made using the corresponding copied nodes.
This method is useful when algorithms return IMapper<K, V> instances that operate on original nodes, but the values should be queried or provided based on the corresponding copied nodes from the structureGraph.
final

Parameters

mapper: IMapper<INode, TValue>
The node-to-value map that will be used for resolving values based on original nodes.

Return Value

IMapper<LayoutNode, TValue>
An IMapper<INode, T> that translates queries for copied nodes into queries for the corresponding original nodes in the provided mapper.

Throws

Exception ({ name: 'ArgumentError' })
Thrown when the provided mapper is null.
Retrieves the copied edge from the structureGraph that corresponds to the specified original edge.
final

Parameters

edge: IEdge
The edge from the originalGraph for which the corresponding copied edge is to be retrieved.

Return Value

LayoutEdge
The LayoutEdge instance that represents edge in the structureGraph, or null if no corresponding copied edge exists.
Retrieves the copied node from the structureGraph that corresponds to the specified original node.
final

Parameters

node: INode
The node from the originalGraph for which the corresponding copied node is to be retrieved.

Return Value

LayoutNode
The LayoutNode instance that represents node in the structureGraph, or null if no corresponding copied node exists.
Retrieves the original edge from the originalGraph that corresponds to the specified copied edge.
final

Parameters

edge: LayoutEdge
The edge from the copied graph for which the corresponding original edge is to be retrieved.

Return Value

IEdge
The original IEdge instance that the given copied edge was created from, or null if no corresponding original edge exists.
Retrieves the original node from the originalGraph that corresponds to the specified copied node.
final

Parameters

node: LayoutNode
The node from the copied graph for which the corresponding original node is to be retrieved.

Return Value

INode
The original INode instance that the given copied node was created from, or null if no corresponding original node exists.