Adaptagrams
Public Member Functions | Friends | List of all members
dialect::Graph Class Reference

The Graph class represents graphs consisting of nodes and edges. More...

#include <graphs.h>

Collaboration diagram for dialect::Graph:
Collaboration graph

Public Member Functions

 Graph (void)
 Default constructor.
 
 Graph (const Graph &G)
 Copy constructor.
 
 ~Graph (void)
 Destructor.
 
Graphoperator= (const Graph other)
 Copy-assignment operator. More...
 
unsigned getMaxDegree (void) const
 Reports the maximum degree of any Node in this Graph. More...
 
void addNode (Node_SP node, bool takeOwnership=true)
 Add a Node to this Graph. More...
 
Node_SP addNode (void)
 Add a new Node to this Graph. More...
 
Node_SP addNode (double w, double h)
 Add a new Node to this Graph, setting dimensions. More...
 
Node_SP addNode (double cx, double cy, double w, double h)
 Add a new Node to this Graph, setting position and dimensions. More...
 
void addEdge (Edge_SP edge, bool takeOwnership=true)
 Add an Edge to this Graph. More...
 
Edge_SP addEdge (Node_SP src, Node_SP tgt)
 Add a new Edge to this Graph. More...
 
Edge_SP addEdge (const id_type &srcID, const id_type &tgtID)
 Add an Edge by specifying the IDs of its endpoint Nodes. More...
 
bool hasNode (const id_type &id) const
 Say whether this Graph has a Node of the given ID. More...
 
bool hasEdge (const id_type &id) const
 Say whether this Graph has an Edge of the given ID. More...
 
void severEdge (dialect::Edge &edge)
 Sever an Edge in this Graph. More...
 
void severNode (const dialect::Node &node)
 Sever all the Edges incident to a Node in this Graph. More...
 
std::vector< Node_SP > severNodeNotingNeighbours (const dialect::Node &node)
 Like severNode but also returns a vector of all Nodes that were neighbours before severing. More...
 
void removeNode (const dialect::Node &node)
 Remove a Node from this Graph. More...
 
void removeNodes (const NodesById &nodes)
 Remove several Nodes from this Graph. More...
 
void severAndRemoveNode (const dialect::Node &node)
 Convenience method to completely remove a Node from the Graph. More...
 
void severAndRemoveNode (id_type nodeID)
 Convenience method to completely remove a Node from the Graph. More...
 
Nodes cloneNode (id_type id)
 Clone a node completely. There will be as many copies of the original node as it had edges, and each clone will be a leaf. More...
 
Node_SP getNode (const id_type &id) const
 Look up a Node by ID. More...
 
const NodesById & getNodeLookup (void) const
 Read-only access to this Graph's lookup map for Nodes by their ID.
 
NodesById getNodeLookupWithIgnore (const Nodes &ignore) const
 Build a NodesById lookup with some Nodes omitted.
 
NodesById getNodeLookupWithIgnore (const NodesById &ignore) const
 Build a NodesById lookup with some Nodes omitted.
 
const EdgesById & getEdgeLookup (void) const
 Read-only access to this Graph's lookup map for Edges by their ID.
 
size_t getNumNodes (void) const
 Say how many Nodes there are in this Graph.
 
size_t getNumEdges (void) const
 Say how many Edges there are in this Graph.
 
bool isEmpty (void) const
 Say whether the Graph is empty, meaning that it has no Nodes.
 
bool isTree (void) const
 Say whether the Graph is a tree.
 
double computeAvgNodeDim (void) const
 Compute the average of all heights and widths of Nodes in this Graph. More...
 
double getIEL (void)
 Read the ideal edge length of this Graph. More...
 
double recomputeIEL (void)
 Recompute, store, and return the Graph's ideal edge length. More...
 
BoundingBox getBoundingBox (const NodesById &ignore=NodesById(), bool includeBends=false) const
 Get the bounding box for this Graph. More...
 
std::vector< Graph_SP > getConnComps (void) const
 Get the connected components of this Graph. More...
 
void getChainsAndCycles (std::vector< std::deque< Node_SP >> &chains, std::vector< std::deque< Node_SP >> &cycles)
 Identify all sequences of consecutive "links" (degree-2 nodes) in this graph. More...
 
std::string writeTglf (bool useExternalIds=false) const
 Write TGLF to represent this Graph. More...
 
std::string writeSvg (bool useExternalIds=false) const
 Write SVG to represent this Graph. More...
 
std::string writeId2Ix (void) const
 Write the Node ID –> Rectangle Index map. Useful for debugging. More...
 
std::string writeIx2Id (void) const
 Write the Rectangle Index –> Node ID map. Useful for debugging. More...
 
void rotate90cw (ColaOptions *opts=nullptr)
 Rotate the layout – and the constraints – 90 degrees clockwise. More...
 
void rotate90acw (ColaOptions *opts=nullptr)
 Rotate the layout – and the constraints – 90 degrees anticlockwise. More...
 
void rotate180 (void)
 Rotate the layout – and the constraints – 180 degrees. More...
 
void translate (double dx, double dy)
 Translate the entire layout by a given amount in each dimension. More...
 
void putInBasePosition (void)
 Put the Graph into a basic position useful for making unit test inputs. The Nodes are put in a row, all Edge routes are cleared, and all constraints are cleared. More...
 
bool hasSameLayoutAs (const Graph &other, double tol=0.001, id_map *idMap=nullptr) const
 Check whether this Graph has the same layout as another, up to a given tolerance. More...
 
SparseIdMatrix2d< Edge_SP >::type getEdgeBySrcIdTgtIdLookup (void) const
 Get a lookup for the Edges of this Graph by the IDs of their source and target Nodes, in that order.
 
void destress (const ColaOptions &opts)
 Reduce stress via libcola's gradient-descent procedures. More...
 
void destress (void)
 Convenience method to destress with default options.
 
void solidifyAlignedEdges (vpsc::Dim dim, const ColaOptions &opts)
 Add Nodes to represent aligned Edges in one dimension, constraining them to stay aligned. More...
 
void makeFeasible (const ColaOptions &opts)
 Make feasible. This means that, among those constraints that offer alternatives, we look for satisfiable alternatives in order of increasing cost (cost = separation violation). This is useful with nonoverlap constraints. More...
 
int project (const ColaOptions &opts, vpsc::Dim dim, int accept=0)
 Project onto cola constraints. More...
 
int projectOntoSepCo (const ColaOptions &opts, SepCo_SP sepco, int accept=0)
 Convenience method to project onto a single SepCo object. Apart from the SepCo, parameters and return value are as for the ordinary project method. More...
 
bool applyProjSeq (const ColaOptions &opts, ProjSeq &ps, int accept=0)
 Attempt to apply the projections given by a ProjSeq object. Give up as soon as any of them fails. More...
 
void updateNodesFromRects (bool xAxis=true, bool yAxis=true)
 For use with various layout actions, this method asks the Graph to update Node positions based on its internal vpsc Rectangles that were used in the layout operation. More...
 
ColaGraphRepupdateColaGraphRep (void)
 Refresh, as needed, the data structures necessary for applying the methods of libcola to this Graph. More...
 
cola::RootClusterbuildRootCluster (const ColaOptions &opts)
 Build a cola::RootCluster based on the node clusters specified in a ColaOptions object. More...
 
ColaGraphRepgetColaGraphRep (void)
 Access the cola graph rep for this Graph.
 
SepMatrix & getSepMatrix (void)
 Access the separation matrix for this Graph.
 
NodesById buildUniqueBendPoints (void)
 Build and return Nodes representing every point at which any Edge has a bend in its connector route. Importantly, for any given point in the plane, at most one Node will built to represent that point, even if different edges have a bend there. While perhaps counterintuitive, this is most helpful in the operation of planarising a given Graph. More...
 
void pushNodePositions (void)
 Save node positions on internal stack.
 
bool popNodePositions (void)
 Restore node positions from internal stack. More...
 
void setEdgeThickness (double t)
 Set the edge thickness.
 
double getEdgeThickness (void)
 Get the edge thickness.
 
void padAllNodes (double dw, double dh)
 Add padding to all ndoes.
 
void setPosesInCorrespNodes (Graph &H)
 Update positions of Nodes in a given Graph to equal those of the corresponding Nodes (same ID) in this Graph. More...
 
void setRoutesInCorrespEdges (Graph &H, bool directed=false)
 Update routes of Edges in a given Graph to equal those of the corresponding Edges (same source and target) in this Graph. More...
 
void route (Avoid::RouterFlag routingType)
 Do a libavoid connector routing on all Edges in the Graph. More...
 
void clearAllRoutes (void)
 Clear all Edge routes.
 
void buildRoutes (void)
 Ask all Edges to build their routes based on their bend nodes.
 
void addBendlessSubnetworkToRoutingAdapter (RoutingAdapter &ra)
 Add all Nodes, and all those Edges having no bend nodes within them, to a given RoutingAdapter. This is useful when precisely those Edges are viewed as needing a route which do not already have any bend nodes. More...
 
void clearAllConstraints (void)
 Clear all constraints in this Graph's SepMatrix.
 
void setCorrespondingConstraints (Graph &H)
 Set corresponding constraints in another Graph. This means that for each constraint between nodes of IDs id1 and id2 in this Graph's SepMatrix, we set that constraint in the other Graph if and only if it too contains Nodes of IDs id1 and id2. More...
 

Friends

void swap (Graph &first, Graph &second)
 Swap operator.
 

Detailed Description

The Graph class represents graphs consisting of nodes and edges.

Member Function Documentation

◆ addBendlessSubnetworkToRoutingAdapter()

void Graph::addBendlessSubnetworkToRoutingAdapter ( RoutingAdapter ra)

Add all Nodes, and all those Edges having no bend nodes within them, to a given RoutingAdapter. This is useful when precisely those Edges are viewed as needing a route which do not already have any bend nodes.

Parameters
[out]raThe RoutingAdapter to which the Nodes and Edges are to be added.

References dialect::RoutingAdapter::addEdges(), and dialect::RoutingAdapter::addNodes().

Here is the call graph for this function:

◆ addEdge() [1/3]

void Graph::addEdge ( Edge_SP  edge,
bool  takeOwnership = true 
)

Add an Edge to this Graph.

Parameters
[in]edgeThe Edge to be added to the Graph.
[in]takeOwnershipControls whether the Edge will record this Graph as being the one to which it belongs.

Referenced by addEdge(), and cloneNode().

Here is the caller graph for this function:

◆ addEdge() [2/3]

Edge_SP Graph::addEdge ( Node_SP  src,
Node_SP  tgt 
)

Add a new Edge to this Graph.

Parameters
[in,out]srcThe source Node.
[in,out]tgtThe target Node.
Note
Nodes are also informed of their linkage to this new Edge.
Returns
The new Edge.

References addEdge(), and dialect::Edge::allocate().

Here is the call graph for this function:

◆ addEdge() [3/3]

Edge_SP Graph::addEdge ( const id_type &  srcID,
const id_type &  tgtID 
)

Add an Edge by specifying the IDs of its endpoint Nodes.

Parameters
[in]srcIDThe ID of the Node that is to sit at the source end of the new Edge.
[in]tgtIDThe ID of the Node that is to sit at the target end of the new Edge.
Returns
A shared pointer to the new Edge.

References addEdge(), and getNode().

Here is the call graph for this function:

◆ addNode() [1/4]

void Graph::addNode ( Node_SP  node,
bool  takeOwnership = true 
)

Add a Node to this Graph.

Parameters
[in]nodeThe Node to be added to the Graph.
[in]takeOwnershipControls whether the Node will record this Graph as being the one to which it belongs.

◆ addNode() [2/4]

Node_SP Graph::addNode ( void  )

Add a new Node to this Graph.

Returns
The new Node.

References dialect::Node::allocate().

Referenced by addNode(), and cloneNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addNode() [3/4]

Node_SP Graph::addNode ( double  w,
double  h 
)

Add a new Node to this Graph, setting dimensions.

Parameters
[in]wWidth of Node.
[in]hHeight of Node.
Returns
The new Node.

References addNode(), and dialect::Node::allocate().

Here is the call graph for this function:

◆ addNode() [4/4]

Node_SP Graph::addNode ( double  cx,
double  cy,
double  w,
double  h 
)

Add a new Node to this Graph, setting position and dimensions.

Parameters
[in]cxCentre x-coordinate of Node.
[in]cyCentre y-coordinate of Node.
[in]wWidth of Node.
[in]hHeight of Node.
Returns
The new Node.

References addNode(), and dialect::Node::allocate().

Here is the call graph for this function:

◆ applyProjSeq()

bool Graph::applyProjSeq ( const ColaOptions opts,
ProjSeq ps,
int  accept = 0 
)

Attempt to apply the projections given by a ProjSeq object. Give up as soon as any of them fails.

Parameters
[in]optsOptions.
[in]psThe ProjSeq to be applied.
[in]acceptAcceptance level. See doctext for cola::projectOntoCCs.
Note
In addition to the zero idealEdgeLength convention employed by the destress method, here a negative idealEdgeLength in the opts parameter may be used to indicate that you do not want the stress changes induced by the projections to be evaluated. Otherwise they will be.
Returns
boolean, saying whether all the projections were successful, at the given acceptance level.

References dialect::ColaOptions::ccs, getIEL(), dialect::ColaOptions::idealEdgeLength, dialect::ProjSeq::nextProjection(), dialect::ProjSeq::noteStresschange(), project(), and updateColaGraphRep().

Here is the call graph for this function:

◆ buildRootCluster()

cola::RootCluster * Graph::buildRootCluster ( const ColaOptions opts)

Build a cola::RootCluster based on the node clusters specified in a ColaOptions object.

Note
The RootCluster will also be stored in the Graph's ColaGraphRep.
Warning
The old RootCluster stored in the Graph's ColaGraphRep (if any) will be deleted.
Returns
The RootCluster.

References cola::Cluster::addChildCluster(), cola::RectangularCluster::addChildNode(), dialect::ColaGraphRep::id2ix, and dialect::ColaOptions::nodeClusters.

Here is the call graph for this function:

◆ buildUniqueBendPoints()

NodesById Graph::buildUniqueBendPoints ( void  )

Build and return Nodes representing every point at which any Edge has a bend in its connector route. Importantly, for any given point in the plane, at most one Node will built to represent that point, even if different edges have a bend there. While perhaps counterintuitive, this is most helpful in the operation of planarising a given Graph.

Note
The new Nodes are /not/ added to the Graph.
As an important side effect, the sequence of Nodes representing the bend points of each Edge is set as the "bend nodes" of that Edge.

References dialect::NearbyObjectFinder< T >::addObject(), dialect::Node::allocate(), dialect::NearbyObjectFinder< T >::findObject(), getIEL(), route(), Avoid::Point::x, and Avoid::Point::y.

Here is the call graph for this function:

◆ cloneNode()

Nodes Graph::cloneNode ( id_type  id)

Clone a node completely. There will be as many copies of the original node as it had edges, and each clone will be a leaf.

Parameters
[in]idThe ID of the node to be cloned.
Returns
Vector of new clones added to the graph.

References addEdge(), addNode(), dialect::Node::allocate(), dialect::Edge::allocate(), getNode(), and severEdge().

Here is the call graph for this function:

◆ computeAvgNodeDim()

double Graph::computeAvgNodeDim ( void  ) const

Compute the average of all heights and widths of Nodes in this Graph.

Returns
The average.

◆ destress()

void Graph::destress ( const ColaOptions opts)

Reduce stress via libcola's gradient-descent procedures.

Parameters
[in]optsoptions to control the layout.
Note
In opts, set the idealEdgeLength to 0 if you want the Graph to automatically supply a reasonable ideal edge length.

References dialect::ColaOptions::logger.

◆ getBoundingBox()

BoundingBox Graph::getBoundingBox ( const NodesById &  ignore = NodesById(),
bool  includeBends = false 
) const

Get the bounding box for this Graph.

Parameters
[in]ignoreOptional set of Nodes (as NodesByID) to leave out of the box.
[in]includeBendsSay whether bend points of connector routes should be included in the box.
Returns
The bounding box.
See also
getBoundingBoxDimensions

Referenced by writeSvg().

Here is the caller graph for this function:

◆ getChainsAndCycles()

void Graph::getChainsAndCycles ( std::vector< std::deque< Node_SP >> &  chains,
std::vector< std::deque< Node_SP >> &  cycles 
)

Identify all sequences of consecutive "links" (degree-2 nodes) in this graph.

Parameters
[out]chainsVector of deques of Nodes, where each identified "chain" will be recorded. A "chain" is a consecutive sequence of "links" whose endpoints are distinct.
[out]cyclesVector of deques of Nodes, where each identified "cycle" will be recorded. A "cycles" is a consecutive sequence of "links" that forms a closed loop.

◆ getConnComps()

vector< Graph_SP > Graph::getConnComps ( void  ) const

Get the connected components of this Graph.

Note that the Nodes and Edges in the component Graphs will be the same objects as those in this Graph.

Returns
A vector of shared pointers to Graphs.

◆ getIEL()

double Graph::getIEL ( void  )

Read the ideal edge length of this Graph.

Note
If the current value is zero (which is true of all new Graphs), the Graph will first auto-infer an ideal edge length equal to twice the average node dimension, store that value, and return it.
Warning
Once this method has been called, the Graph will NOT recompute its IEL on subsequent calls, even if Nodes have been added or taken away.
See also
Graph::recomputeIEL

Referenced by applyProjSeq(), buildUniqueBendPoints(), and dialect::doHOLA().

Here is the caller graph for this function:

◆ getMaxDegree()

unsigned Graph::getMaxDegree ( void  ) const

Reports the maximum degree of any Node in this Graph.

The value is automatically maintained as you add or remove Nodes from the Graph.

Returns
Maximum degree of any Node in the Graph.

◆ getNode()

Node_SP Graph::getNode ( const id_type &  id) const

Look up a Node by ID.

Exceptions
out_of_rangeexception if there is no Node by the given ID.
Returns
The Node with the given ID, if present.

Referenced by addEdge(), cloneNode(), dialect::identifyRootNode(), dialect::peel(), and severAndRemoveNode().

Here is the caller graph for this function:

◆ hasEdge()

bool Graph::hasEdge ( const id_type &  id) const

Say whether this Graph has an Edge of the given ID.

Returns
boolean

◆ hasNode()

bool Graph::hasNode ( const id_type &  id) const

Say whether this Graph has a Node of the given ID.

Returns
boolean

Referenced by dialect::TreePlacement::insertTreeIntoGraph().

Here is the caller graph for this function:

◆ hasSameLayoutAs()

bool Graph::hasSameLayoutAs ( const Graph other,
double  tol = 0.001,
id_map *  idMap = nullptr 
) const

Check whether this Graph has the same layout as another, up to a given tolerance.

Note
Checks Node positions and Edge routes, but not constraints.
Parameters
[in]otherThe other Graph.
[in]tolTolerance for checking equality of floats.
[in]idMapOptional mapping from the IDs of the other Graph to the IDs of the corresponding Nodes of this Graph. If not provided, the correspondence is by the Nodes' external IDs.

References getEdgeBySrcIdTgtIdLookup(), getNodeLookup(), Avoid::Point::x, and Avoid::Point::y.

Here is the call graph for this function:

◆ makeFeasible()

void Graph::makeFeasible ( const ColaOptions opts)

Make feasible. This means that, among those constraints that offer alternatives, we look for satisfiable alternatives in order of increasing cost (cost = separation violation). This is useful with nonoverlap constraints.

Parameters
[in]optsThe usual ColaOptions.
Note
Simply uses the method by the same name in the cola::ConstrainedFDLayout class.

References dialect::ColaOptions::logger.

◆ operator=()

Graph & Graph::operator= ( const Graph  other)

Copy-assignment operator.

Note
Pass-by-value is deliberate. See https://stackoverflow.com/a/3279550

References swap.

◆ popNodePositions()

bool Graph::popNodePositions ( void  )

Restore node positions from internal stack.

Returns
true if positions were restored; false if stack was empty

References Avoid::Point::x, and Avoid::Point::y.

◆ project()

int Graph::project ( const ColaOptions opts,
vpsc::Dim  dim,
int  accept = 0 
)

Project onto cola constraints.

Parameters
[in]optsOptions, including any additional constraints onto which to project (in addition to the Graph's existing SepMatrix).
Note
All options relating to edge length are ignored, since this is only a projection.
Parameters
[in]dimThe dimension in which to project.
[in]acceptAcceptance level. See doctext for cola::projectOntoCCs.
Returns
Error level. See cola::projectOntoCCs.

References dialect::ColaOptions::solidifyAlignedEdges.

Referenced by applyProjSeq(), and projectOntoSepCo().

Here is the caller graph for this function:

◆ projectOntoSepCo()

int Graph::projectOntoSepCo ( const ColaOptions opts,
SepCo_SP  sepco,
int  accept = 0 
)

Convenience method to project onto a single SepCo object. Apart from the SepCo, parameters and return value are as for the ordinary project method.

See also
Graph::project.

References dialect::ColaOptions::ccs, project(), and updateColaGraphRep().

Here is the call graph for this function:

◆ putInBasePosition()

void Graph::putInBasePosition ( void  )

Put the Graph into a basic position useful for making unit test inputs. The Nodes are put in a row, all Edge routes are cleared, and all constraints are cleared.

The criteria are: (1) all nodes have distinct positions, and (2) the layout is a bad one. Condition (1) is needed so that Cola doesn't generate random starting positions.

References clearAllConstraints(), and clearAllRoutes().

Here is the call graph for this function:

◆ recomputeIEL()

double Graph::recomputeIEL ( void  )

Recompute, store, and return the Graph's ideal edge length.

Note
As in the getIEL method, the value will be twice the average dimension of Nodes currently in the Graph.
See also
Graph::getIEL

◆ removeNode()

void Graph::removeNode ( const dialect::Node node)

Remove a Node from this Graph.

Note
This method only removes the Node itself; it does not also sever the incident Edges.
Parameters
[in]nodeThe Node to be removed from the Graph.
See also
severAndRemoveNode

References dialect::Node::id().

Referenced by severAndRemoveNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ removeNodes()

void Graph::removeNodes ( const NodesById &  nodes)

Remove several Nodes from this Graph.

Parameters
[in]nodesThe Nodes to be removed from the Graph.
See also
removeNode

Referenced by dialect::NodeBuckets::severNodes().

Here is the caller graph for this function:

◆ rotate180()

void Graph::rotate180 ( void  )

Rotate the layout – and the constraints – 180 degrees.

Note
Unlinke the 90-degree rotations, rotating 180 degrees can be viewed as a simple rigid transformation, and there is no reason to destress afterward.
See also
Graph::rotate90cw
Graph::rotate90acw

References dialect::EAST.

◆ rotate90acw()

void Graph::rotate90acw ( ColaOptions opts = nullptr)

Rotate the layout – and the constraints – 90 degrees anticlockwise.

Parameters
[in]optsColaOptions to control destressing operation after rotation. This is optional; pass nullptr if you do not want to destress.
Note
If any nodes are non-square, i.e. have aspect ratio different from 1:1, then destressing is recommended after a 90-degree rotation. The relationships between oblong nodes can change dramatically when rotating 90 degrees.
See also
Graph::rotate90cw
Graph::rotate180

References dialect::EAST.

◆ rotate90cw()

void Graph::rotate90cw ( ColaOptions opts = nullptr)

Rotate the layout – and the constraints – 90 degrees clockwise.

Parameters
[in]optsColaOptions to control destressing operation after rotation. This is optional; pass nullptr if you do not want to destress.
Note
If any nodes are non-square, i.e. have aspect ratio different from 1:1, then destressing is recommended after a 90-degree rotation. The relationships between oblong nodes can change dramatically when rotating 90 degrees.
See also
Graph::rotate90acw
Graph::rotate180

References dialect::EAST.

◆ route()

void Graph::route ( Avoid::RouterFlag  routingType)

Do a libavoid connector routing on all Edges in the Graph.

Parameters
[in]routingTypeThe type of routing you want (orthogonal or polyline).

References dialect::RoutingAdapter::addEdges(), dialect::RoutingAdapter::addNodes(), clearAllRoutes(), and dialect::RoutingAdapter::route().

Referenced by buildUniqueBendPoints().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setCorrespondingConstraints()

void Graph::setCorrespondingConstraints ( Graph H)

Set corresponding constraints in another Graph. This means that for each constraint between nodes of IDs id1 and id2 in this Graph's SepMatrix, we set that constraint in the other Graph if and only if it too contains Nodes of IDs id1 and id2.

Parameters
[out]HThe other Graph.

◆ setPosesInCorrespNodes()

void Graph::setPosesInCorrespNodes ( Graph H)

Update positions of Nodes in a given Graph to equal those of the corresponding Nodes (same ID) in this Graph.

Parameters
[out]HThe Graph whose Node positions are to be updated.

◆ setRoutesInCorrespEdges()

void Graph::setRoutesInCorrespEdges ( Graph H,
bool  directed = false 
)

Update routes of Edges in a given Graph to equal those of the corresponding Edges (same source and target) in this Graph.

Parameters
[out]HThe Graph whose Edge routes are to be updated.
[in]directedSet true if Edges are to be understood as directed, i.e. if in order to match the Edges have to have the same source and the same target. Otherwise only the set {source ID, target ID} has to be the same. Default: false (i.e. undirected edges).

◆ severAndRemoveNode() [1/2]

void Graph::severAndRemoveNode ( const dialect::Node node)

Convenience method to completely remove a Node from the Graph.

See also
severNode
removeNode

References removeNode(), and severNode().

Referenced by dialect::TreePlacement::insertTreeIntoGraph(), and severAndRemoveNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ severAndRemoveNode() [2/2]

void Graph::severAndRemoveNode ( id_type  nodeID)

Convenience method to completely remove a Node from the Graph.

See also
severNode
removeNode

References getNode(), and severAndRemoveNode().

Here is the call graph for this function:

◆ severEdge()

void Graph::severEdge ( dialect::Edge edge)

Sever an Edge in this Graph.

The Edge is removed from the Graph, and from both of its endpoint Nodes as well.

Parameters
[in]edgeThe Edge to be severed from the Graph.

References dialect::Edge::id(), and dialect::Edge::sever().

Referenced by cloneNode(), severNode(), and severNodeNotingNeighbours().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ severNode()

void Graph::severNode ( const dialect::Node node)

Sever all the Edges incident to a Node in this Graph.

Note
This method only cuts the incident Edges; it does /not/ also remove the Node itself from the Graph.
Parameters
[in]nodeThe Node whose Edges are to be severed.
See also
severAndRemoveNode

References dialect::Node::getCopyOfEdgeLookup(), and severEdge().

Referenced by severAndRemoveNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ severNodeNotingNeighbours()

vector< Node_SP > Graph::severNodeNotingNeighbours ( const dialect::Node node)

Like severNode but also returns a vector of all Nodes that were neighbours before severing.

See also
severNode

References dialect::Node::getEdgeLookup(), and severEdge().

Referenced by dialect::NodeBuckets::severNodes().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ solidifyAlignedEdges()

void Graph::solidifyAlignedEdges ( vpsc::Dim  dim,
const ColaOptions opts 
)

Add Nodes to represent aligned Edges in one dimension, constraining them to stay aligned.

Parameters
[in]dimSolidify only those aligned Edges whose variable coordinate is in this dimension. Thus, horizontally aligned edges for XDIM; vertically aligned for YDIM.
[in]optsHere you can set Edge exemptions, i.e. a set of Edges that should not be solidified.

References dialect::Node::allocate(), vpsc::HORIZONTAL, Avoid::Point::id, dialect::ColaOptions::solidEdgeExemptions, vpsc::VERTICAL, Avoid::Point::x, and Avoid::Point::y.

Here is the call graph for this function:

◆ translate()

void Graph::translate ( double  dx,
double  dy 
)

Translate the entire layout by a given amount in each dimension.

Parameters
[in]dxThe amount by which to translate in the x-dimension.
[in]dyThe amount by which to translate in the y-dimension.

◆ updateColaGraphRep()

ColaGraphRep & Graph::updateColaGraphRep ( void  )

Refresh, as needed, the data structures necessary for applying the methods of libcola to this Graph.

Warning
If Nodes have been added to or removed from the Graph since the last time this method was called, the old Rectangles will be deleted.

Clients are therefore advised to utilise methods like Graph::destress instead of creating their own instances of ConstrainedFDLayout. At the least, they must not reuse layout objects that were created before adding or removing Nodes from the Graph (which makes sense anyway).

Returns
A reference to the (updated) ColaGraphRep.

References dialect::ColaGraphRep::id2ix, and dialect::ColaGraphRep::ix2id.

Referenced by applyProjSeq(), and projectOntoSepCo().

Here is the caller graph for this function:

◆ updateNodesFromRects()

void Graph::updateNodesFromRects ( bool  xAxis = true,
bool  yAxis = true 
)

For use with various layout actions, this method asks the Graph to update Node positions based on its internal vpsc Rectangles that were used in the layout operation.

Parameters
[in]xAxisSet true iff the x-coordinates of the nodes should be updated.
[in]yAxisSet true iff the y-coordinates of the nodes should be updated.

References dialect::ColaGraphRep::id2ix.

◆ writeId2Ix()

string Graph::writeId2Ix ( void  ) const

Write the Node ID –> Rectangle Index map. Useful for debugging.

Returns
String representation of the map.

References dialect::ColaGraphRep::id2ix.

◆ writeIx2Id()

string Graph::writeIx2Id ( void  ) const

Write the Rectangle Index –> Node ID map. Useful for debugging.

Returns
String representation of the map.

References dialect::ColaGraphRep::ix2id.

◆ writeSvg()

string Graph::writeSvg ( bool  useExternalIds = false) const

Write SVG to represent this Graph.

Parameters
[in]useExternalIdsWhen a Graph is built from TGLF its Nodes store the IDs that were used there. Set true if you want these same IDs to be written out as well. Otherwise the internal unique Node IDs are used.
Returns
A string containing the SVG.

References getBoundingBox(), dialect::BoundingBox::h(), dialect::string_format(), and dialect::BoundingBox::w().

Here is the call graph for this function:

◆ writeTglf()

string Graph::writeTglf ( bool  useExternalIds = false) const

Write TGLF to represent this Graph.

Parameters
[in]useExternalIdsWhen a Graph is built from TGLF its Nodes store the IDs that were used there. Set true if you want these same IDs to be written out as well. Otherwise the internal unique Node IDs are used.
Returns
A string containing the TGLF.

References Avoid::Point::x, and Avoid::Point::y.


The documentation for this class was generated from the following files: