40namespace vpsc {
class Rectangle; }
42 class ColaTopologyAddon;
58class NonOverlapConstraints;
59class NonOverlapConstraintExemptions;
68typedef std::pair<unsigned, unsigned>
Edge;
73#define StandardEdgeLengths EdgeLengths()
88 Lock(
unsigned id,
double X,
double Y) :
id(
id),
x(X),
y(Y) {
102typedef std::vector<cola::Lock>
Locks;
122 Resize(
unsigned id,
double x,
double y,
double w,
double h)
226 virtual bool operator()(
const double new_stress, std::valarray<double> & X, std::valarray<double> & Y)
294 std::vector<Edge>
const &
es,
296 const double idealLength,
300 bool useNeighbourStress =
false);
314 for (
size_t i = 0; i <
ccs.size(); ++i) {
315 ccsp->push_back(
ccs.at(i));
346 std::valarray<double>
const &
startX,
347 std::valarray<double>
const &
startY);
388 for(std::vector<straightener::Edge*>::const_iterator e=
straightenEdges->begin();
402 for(
unsigned i=0;i<
n;i++) {
427 void run(
bool x=
true,
bool y=
true);
439 void runOnce(
bool x=
true,
bool y=
true);
448 (
X[i] -
X[j]) * (
X[i] -
X[j]) +
449 (
Y[i] -
Y[j]) * (
Y[i] -
Y[j]));
452 void majorize(std::valarray<double>
const &
Dij,
GradientProjection* gp, std::valarray<double>& coords, std::valarray<double>
const & startCoords);
453 void newton(std::valarray<double>
const &
Dij,
GradientProjection* gp, std::valarray<double>& coords, std::valarray<double>
const & startCoords);
457 std::valarray<double>
Q;
458 std::valarray<double>
Dij;
469 std::valarray<double>
X,
Y;
552 std::valarray<double>& X, std::valarray<double>& Y,
557 COLA_UNUSED(resizeList);
562 COLA_UNUSED(boundingBoxes);
563 COLA_UNUSED(clusterHierarchy);
581 COLA_UNUSED(generateNonOverlapConstraints);
582 COLA_UNUSED(boundingBoxes);
583 COLA_UNUSED(clusterHierarchy);
593 COLA_UNUSED(clusterHierarchy);
596 const vpsc::Dim dim, std::valarray<double>& g,
598 std::valarray<double> &coords,
608 COLA_UNUSED(oldStress);
654 const std::vector<cola::Edge>&
es,
655 const double idealLength,
670 void run(
bool x=
true,
bool y=
true);
683 void runOnce(
bool x=
true,
bool y=
true);
863 std::valarray<double>
X,
Y;
867 const std::valarray<double>& d)
const;
869 double stress, std::valarray<double>& x0, std::valarray<double>& x1);
872 const std::valarray<double>& d,
873 const std::valarray<double>& oldCoords,
874 std::valarray<double> &coords,
875 const double oldStress,
879 const std::vector<Edge>&
es, std::valarray<double> eLengths);
887 std::valarray<double> &g);
948 bool preventOverlaps,
int accept=0,
unsigned debugLevel=0);
966 unsigned debugLevel=0);
971 std::vector<Edge>
const &
es,
973 const double idealLength,
974 bool useNeighbourStress =
false
985void dijkstra(
const unsigned s,
const unsigned n,
double* d,
986 const std::vector<cola::Edge>&
es,
987 const std::valarray<double> & eLengths);
997 std::valarray<double> &coords);
A cluster defines a hierarchical partitioning over the nodes which should be kept disjoint by the lay...
Implements a constrained force-directed layout algorithm.
RootCluster * clusterHierarchy
void run(bool x=true, bool y=true)
Implements the main layout loop, taking descent steps until stress is no-longer significantly reduced...
void computeDescentVectorOnBothAxes(const bool xaxis, const bool yaxis, double stress, std::valarray< double > &x0, std::valarray< double > &x1)
void freeAssociatedObjects(void)
A convenience method that can be called from Java to free the memory of nodes (Rectangles),...
DesiredPositions * desiredPositions
bool m_generateNonOverlapConstraints
void computeNeighbours(std::vector< Edge > es)
void setConstraints(const cola::CompoundConstraints &ccs)
Specify a set of compound constraints to apply to the layout.
std::vector< std::vector< unsigned > > neighbours
void computePathLengths(const std::vector< Edge > &es, std::valarray< double > eLengths)
std::vector< double > offsetDir(double minD)
double applyDescentVector(const std::valarray< double > &d, const std::valarray< double > &oldCoords, std::valarray< double > &coords, const double oldStress, double stepsize)
void setPosition(std::valarray< double > &pos)
TopologyAddonInterface * topologyAddon
std::vector< std::vector< double > > neighbourLengths
double applyForcesAndConstraints(const vpsc::Dim dim, const double oldStress)
void setUnsatisfiableConstraintInfo(UnsatisfiableConstraintInfos *unsatisfiableX, UnsatisfiableConstraintInfos *unsatisfiableY)
Register to receive information about unsatisfiable constraints.
vpsc::Rectangles boundingBoxes
TopologyAddonInterface * getTopology(void)
std::vector< unsigned > readLinearG(void)
Retrieve a copy of the "G matrix" computed by the computePathLengths method, linearised as a vector.
double computeStepSize(const SparseMatrix &H, const std::valarray< double > &g, const std::valarray< double > &d) const
void setTopology(TopologyAddonInterface *topology)
Set an addon for doing topology preserving layout.
NonOverlapConstraintExemptions * m_nonoverlap_exemptions
void setDesiredPositions(DesiredPositions *desiredPositions)
std::valarray< double > Y
double computeStress() const
std::valarray< double > X
void computeForces(const vpsc::Dim dim, SparseMap &H, std::valarray< double > &g)
void handleResizes(const Resizes &)
std::vector< double > readLinearD(void)
Retrieve a copy of the "D matrix" computed by the computePathLengths method, linearised as a vector.
std::vector< UnsatisfiableConstraintInfos * > unsatisfiable
const std::valarray< double > m_edge_lengths
bool noForces(double, double, unsigned) const
void moveTo(const vpsc::Dim dim, std::valarray< double > &target)
void makeFeasible(double xBorder=1, double yBorder=1)
Finds a feasible starting position for nodes that satisfies the given constraints.
bool m_useNeighbourStress
void setAvoidNodeOverlaps(bool avoidOverlaps, ListOfNodeIndexes listOfNodeGroups=ListOfNodeIndexes())
Specifies whether non-overlap constraints should be automatically generated between all nodes,...
cola::CompoundConstraints ccs
void generateNonOverlapAndClusterCompoundConstraints(vpsc::Variables(&vs)[2])
void recGenerateClusterVariablesAndConstraints(vpsc::Variables(&vars)[2], unsigned int &priority, cola::NonOverlapConstraints *noc, Cluster *cluster, cola::CompoundConstraints &idleConstraints)
friend class topology::ColaTopologyAddon
void outputInstanceToSVG(std::string filename=std::string())
Generates an SVG file containing debug output and code that can be used to regenerate the instance.
cola::CompoundConstraints extraConstraints
PreIteration * preIteration
void runOnce(bool x=true, bool y=true)
Same as run(), but only applies one iteration.
void setUseNeighbourStress(bool useNeighbourStress)
Specifies whether neighbour stress should be used.
friend class dialect::Graph
void setClusterHierarchy(RootCluster *hierarchy)
Specifies an optional hierarchy for clustering nodes.
Implements the Constrained Majorization graph layout algorithm (deprecated).
std::valarray< double > Q
void setConstrainedLayout(bool c)
void setAvoidOverlaps(bool horizontal=false)
At each iteration of layout, generate constraints to avoid overlaps.
std::valarray< double > X
void runOnce(bool x=true, bool y=true)
Same as run(), but only applies one iteration.
std::valarray< double > lap2
std::valarray< double > Dij
void setConstraintsVector(cola::CompoundConstraints &ccs)
void setExternalSolver(bool externalSolver)
Says that the Mosek optimisation library should be used to solve the quadratic programs rather than t...
double euclidean_distance(unsigned i, unsigned j)
cola::CompoundConstraints * ccs
PreIteration * preIteration
void newton(std::valarray< double > const &Dij, GradientProjection *gp, std::valarray< double > &coords, std::valarray< double > const &startCoords)
std::valarray< double > startX
RootCluster * clusterHierarchy
vpsc::Rectangles boundingBoxes
bool nonOverlappingClusters
void straighten(std::vector< straightener::Edge * > &, vpsc::Dim)
void setUnsatisfiableConstraintInfo(UnsatisfiableConstraintInfos *unsatisfiableX, UnsatisfiableConstraintInfos *unsatisfiableY)
Register to receive information about unsatisfiable constraints.
~ConstrainedMajorizationLayout()
UnsatisfiableConstraintInfos * unsatisfiableX
NonOverlapConstraintsMode avoidOverlaps
void setStickyNodes(const double stickyWeight, std::valarray< double > const &startX, std::valarray< double > const &startY)
Sticky nodes causes nodes to spring back to (startX,startY) when unconstrained.
std::valarray< double > Y
void moveBoundingBoxes()
Update position of bounding boxes.
double compute_stress(std::valarray< double > const &Dij)
void setScaling(bool scaling)
Scaling speeds up the solver by conditioning the quadratic terms matrix.
void setStraightenEdges(std::vector< straightener::Edge * > *straightenEdges, double bendWeight=0.01, double potBendWeight=0.1, bool xSkipping=true)
For the specified edges (with routings), generate dummy vars and constraints to try and straighten th...
std::vector< straightener::Edge * > * straightenEdges
void setConstraints(cola::CompoundConstraints *ccs)
Specify a set of compound constraints to apply to the layout.
UnsatisfiableConstraintInfos * unsatisfiableY
std::valarray< double > startY
void run(bool x=true, bool y=true)
Implements the main layout loop, taking descent steps until stress is no-longer significantly reduced...
void setNonOverlappingClusters()
Add constraints to prevent clusters overlapping.
void majorize(std::valarray< double > const &Dij, GradientProjection *gp, std::valarray< double > &coords, std::valarray< double > const &startCoords)
A Lock specifies a required position for a node.
Lock(unsigned id, double X, double Y)
Constructs a Lock object for a given node and position.
double pos(vpsc::Dim dim) const
A default functor that is called before each iteration in the main loop of the ConstrainedFDLayout::r...
virtual bool operator()()
static Resizes __resizesNotUsed
PreIteration(Locks &locks=__locksNotUsed, Resizes &resizes=__resizesNotUsed)
Constructs a PreIteration object that handles locking and resizing of nodes.
static Locks __locksNotUsed
PreIteration(Resizes &resizes)
A Resize specifies a new required bounding box for a node.
const vpsc::Rectangle * getTarget() const
Resize(unsigned id, double x, double y, double w, double h)
Constructs a Resize object for a given node and it's new bounding box.
Holds the cluster hierarchy specification for a diagram.
A default functor that is called after each iteration of the layout algorithm.
TestConvergence(const double tol=1e-4, const unsigned maxiterations=100)
const unsigned maxiterations
virtual ~TestConvergence()
virtual bool operator()(const double new_stress, std::valarray< double > &X, std::valarray< double > &Y)
Interface for writing COLA addons to handle topology preserving layout.
virtual double applyForcesAndConstraints(ConstrainedFDLayout *layout, const vpsc::Dim dim, std::valarray< double > &g, vpsc::Variables &vs, vpsc::Constraints &cs, std::valarray< double > &coords, DesiredPositionsInDim &des, double oldStress)
virtual bool useTopologySolver(void) const
virtual void freeAssociatedObjects(void)
virtual double computeStress(void) const
virtual TopologyAddonInterface * clone(void) const
virtual void makeFeasible(bool generateNonOverlapConstraints, vpsc::Rectangles &boundingBoxes, cola::RootCluster *clusterHierarchy)
virtual void computePathLengths(unsigned short **G)
virtual void moveTo(const vpsc::Dim dim, vpsc::Variables &vs, vpsc::Constraints &cs, std::valarray< double > &coords, cola::RootCluster *clusterHierarchy)
virtual void handleResizes(const Resizes &resizeList, unsigned n, std::valarray< double > &X, std::valarray< double > &Y, cola::CompoundConstraints &ccs, vpsc::Rectangles &boundingBoxes, cola::RootCluster *clusterHierarchy)
virtual ~TopologyAddonInterface()
A rectangle represents a fixed-size shape in the diagram that may be moved to prevent overlaps and sa...
vector< vpsc::Rectangle * > rs
libcola: Force-directed network layout subject to separation constraints library.
ProjectionResult solve(vpsc::Variables &vs, vpsc::Constraints &cs, vpsc::Rectangles &rs, unsigned debugLevel=0)
Constructs a solver and attempts to solve the passed constraints on the passed vars.
std::vector< cola::Lock > Locks
A vector of Lock objects.
std::vector< CompoundConstraint * > CompoundConstraints
A vector of pointers to CompoundConstraint objects.
void setVariableDesiredPositions(vpsc::Variables &vs, vpsc::Constraints &cs, const DesiredPositionsInDim &des, std::valarray< double > &coords)
void removeClusterOverlapFast(RootCluster &clusterHierarchy, vpsc::Rectangles &rs, Locks &locks)
std::vector< cola::Resize > Resizes
A vector of Resize objects.
void setupVarsAndConstraints(unsigned n, const CompoundConstraints &ccs, const vpsc::Dim dim, vpsc::Rectangles &boundingBoxes, RootCluster *clusterHierarchy, vpsc::Variables &vs, vpsc::Constraints &cs, std::valarray< double > &coords)
ConstrainedMajorizationLayout * simpleCMLFactory(vpsc::Rectangles &rs, std::vector< Edge > const &es, RootCluster *clusterHierarchy, const double idealLength, bool useNeighbourStress)
NonOverlapConstraintsMode
std::vector< UnsatisfiableConstraintInfo * > UnsatisfiableConstraintInfos
A vector of pointers to UnsatisfiableConstraintInfo objects.
std::vector< unsigned > NodeIndexes
A vector of node Indexes.
std::vector< cola::DesiredPosition > DesiredPositions
std::vector< NodeIndexes > ListOfNodeIndexes
A vector of NodeIndexes.
void dijkstra(const unsigned s, const unsigned n, double *d, const std::vector< cola::Edge > &es, const std::valarray< double > &eLengths)
std::pair< unsigned, unsigned > Edge
Edges are simply a pair of indices to entries in the Node vector.
ProjectionResult projectOntoCCs(vpsc::Dim dim, vpsc::Rectangles &rs, cola::CompoundConstraints ccs, bool preventOverlaps, int accept=0, unsigned debugLevel=0)
Attempt to do a projection onto a vector of cola CompoundConstraints.
std::pair< unsigned, double > DesiredPositionInDim
std::vector< double > EdgeLengths
EdgeLengths is a vector of ideal lengths for edges corresponding to edges in the edge list.
std::vector< DesiredPositionInDim > DesiredPositionsInDim
libvpsc: Variable Placement with Separation Constraints quadratic program solver library.
Dim
Indicates the x- or y-dimension.
@ HORIZONTAL
The x-dimension (0).
std::vector< vpsc::Variable * > Variables
A vector of pointers to Variable objects.
std::vector< vpsc::Constraint * > Constraints
A vector of pointers to Constraint objects.
std::vector< Rectangle * > Rectangles
A vector of pointers to Rectangle objects.