MeVisLab Toolbox Reference
Graph Class Reference

Defines the basic Graph class which holds sets of nodes, edges and roots to model tubular structures with graph-like topologies such as vascular systems. More...

#include <mlGraph.h>

Inheritance diagram for Graph:

Public Types

enum  { node , edge }
 Global graph item-type enumeration. More...
 
enum  ActionType {
  NoAction =0 , LabelGraph , EditGraph , ModifyRoots ,
  ModifyNodesEdges , NewGraph , NumActionTypes
}
 Graph modification modes. Ordered from minor to mayor modifications. More...
 
typedef std::map< MLint, VesselNode * > NodeMap
 Internal node storage. More...
 
typedef boost::function< VesselNode *(const NodeMap::value_type &) > NodeAccess
 Helper function returning the VesselNode from a key/value pair of a NodeMap. More...
 
typedef boost::function< const VesselNode *(const NodeMap::value_type &) > ConstNodeAccess
 Helper function returning the VesselNode as const from a key/value pair of a NodeMap. More...
 
typedef boost::transform_iterator< NodeAccess, NodeMap::iterator > NodeIterator
 Iterator used to traverse nodes in a node map (returns data elements of the map instead of tuples). More...
 
typedef boost::transform_iterator< ConstNodeAccess, NodeMap::const_iterator > ConstNodeIterator
 Iterator used to traverse const nodes in a node map (returns data elements of the map instead of tuples). More...
 
typedef std::map< MLint, VesselEdge * > EdgeMap
 Internal edge storage. More...
 
typedef boost::function< VesselEdge *(const EdgeMap::value_type &) > EdgeAccess
 Helper function returning the VesselEdge from a key/value pair of a EdgeMap. More...
 
typedef boost::function< const VesselEdge *(const EdgeMap::value_type &) > ConstEdgeAccess
 Helper function returning the VesselEdge as const from a key/value pair of a EdgeMap. More...
 
typedef boost::transform_iterator< EdgeAccess, EdgeMap::iterator > EdgeIterator
 Iterator used to traverse edges in a edge map (returns data elements of the map instead of tuples). More...
 
typedef boost::transform_iterator< ConstEdgeAccess, EdgeMap::const_iterator > ConstEdgeIterator
 Iterator used to traverse const edges in a edge map (returns data elements of the map instead of tuples). More...
 

Public Member Functions

MLint splitEdge (MLint edgeID, size_t skeletonIndex)
 Splits edge with id edgeID at skeleton index skeletonIndex and returns the ID of the additionally created edge. More...
 
bool mergeEdges (VesselEdge *parent, VesselEdge *child)
 
int getNumCluster () const
 
bool getFlag () const
 
void setFlag (bool bFlag)
 
void closeSkeletonGaps ()
 Closes gaps in the skeletons between the first or last skeleton of a VesselEdge and the closest node. More...
 
void clampToImage ()
 
void setRootIdToAllChildren ()
 Descends recursively from all roots to the leaves in the trees and sets the rootId of the according root to all child items (edges and nodes). More...
 
void purifyGraph ()
 Removes orphan nodes and unsets false cyclic edges (edges with a leaf node that are marked as cyclic). More...
 
void removeOrphanNodes ()
 Remove nodes with no edges attached. More...
 
Initialization
 Graph ()
 Default constructor. More...
 
 Graph (const Graph &g, bool reorder=false)
 Default copy constructor. More...
 
 Graph (const Graph &g, const VesselNode *root, bool reorder=false)
 Construct graph from tree in g. More...
 
 Graph (const Graph &g, const std::vector< const VesselNode * > &roots, bool reorder=false)
 Construct graph from trees in g. More...
 
 Graph (Graph &g, int clusterId, bool reorder=false)
 Construct graph from subgraph of g, defined by clusterId in g. More...
 
GraphdeepCopy () const override
 Implement generic deepCopy functionality using copy constructor. More...
 
 ~Graph () override
 Destructor. More...
 
Creating Elements
VesselEdgecreateEdge (VesselNode *predNode, VesselNode *succNode, MLint useId=-1)
 Create a VesselEdge with unique id, add it to the Graph and Nodes and return a pointer to it. More...
 
VesselEdgecreateEdge (MLint predNodeId, MLint succNodeId, MLint useId=-1)
 Create a VesselEdge with unique id, add it to the Graph and Nodes identified by the respective IDs and return a pointer to it. More...
 
VesselNodecreateNode (const Vector3 &pos=Vector3(0), MLint useId=-1)
 Create a VesselNode with unique id, add it to the Graph and return a pointer to it. More...
 
VesselNodecreateNode (const ImageVector &pos, MLint useId=-1)
 Create a VesselNode with unique id, add it to the Graph and return a pointer to it. More...
 
void insertRoot (VesselNode *node)
 Insert a node to the list of root nodes. More...
 
Copying Elements
void addGraph (const Graph &g)
 Add an entire graph to the current graph. More...
 
void addGraph (const Graph &g, std::map< const VesselNode *, VesselNode * > &nodeMapping, std::map< const VesselEdge *, VesselEdge * > &edgeMapping, std::map< const VesselNode *, VesselNode * > &rootMapping)
 Add an entire graph to this graph. More...
 
void addSubtrees (const std::vector< const VesselNode * > &roots)
 Add subtrees rooted at nodes roots to this graph. More...
 
void copyParts (const std::vector< const VesselNode * > &nodes, const std::vector< const VesselEdge * > &edges, const std::vector< const VesselNode * > &roots)
 Copy a collection of nodes, edges and roots from a different graph to this graph. More...
 
void copyParts (const std::vector< const VesselNode * > &nodes, const std::vector< const VesselEdge * > &edges, const std::vector< const VesselNode * > &roots, std::map< const VesselNode *, VesselNode * > &nodeMapping, std::map< const VesselEdge *, VesselEdge * > &edgeMapping, std::map< const VesselNode *, VesselNode * > &rootMapping)
 Copy a collection of nodes, edges and roots from a different graph to this graph. More...
 
Removing Elements
bool removeEdge (VesselEdge *edge, bool removeEmptyNodes=true)
 Remove an edge from the graph. More...
 
bool removeNode (VesselNode *node)
 Remove a node from the graph. More...
 
void removeRoot (VesselNode *r)
 Remove a root from the graph. More...
 
void clearRoots ()
 Remove all roots that have been defined. More...
 
void clearGraph ()
 Remove all elements from the graph. More...
 
Accessing Elements
NodeIterator beginNode ()
 Provide iterator access to the begin of the node map. More...
 
NodeIterator endNode ()
 Provide iterator access to the end of the node map. More...
 
ConstNodeIterator beginNode () const
 Provide const iterator access to the begin of the node map. More...
 
ConstNodeIterator endNode () const
 Provide const iterator access to the end of the node map. More...
 
EdgeIterator beginEdge ()
 Provide iterator access to the begin of the edge map. More...
 
EdgeIterator endEdge ()
 Provide iterator access to the end of the edge map. More...
 
ConstEdgeIterator beginEdge () const
 Provide const iterator access to the begin of the edge map. More...
 
ConstEdgeIterator endEdge () const
 Provide const iterator access to the end of the edge map. More...
 
NodeIterator beginRoot ()
 Provide iterator access to the begin of the root map. More...
 
NodeIterator endRoot ()
 Provide iterator access to the end of the root map. More...
 
ConstNodeIterator beginRoot () const
 Provide const iterator access to the begin of the root map. More...
 
ConstNodeIterator endRoot () const
 Provide const iterator access to the end of the root map. More...
 
size_t numNodes () const
 Returns the number nodes in this graph. More...
 
size_t numEdges () const
 Returns the number edges in this graph. More...
 
size_t numRoots () const
 Returns the number roots in this graph. More...
 
const VesselNodegetIdNode (MLint id) const
 Get node with id id;. More...
 
VesselNodegetIdNode (MLint id)
 Get node with id id;. More...
 
const VesselEdgegetIdEdge (MLint id) const
 Get edge with id id. More...
 
VesselEdgegetIdEdge (MLint id)
 Get edge with id id. More...
 
const VesselNodegetNode (Vector3 pos) const
 Get the node with minimal distance to \cpos. Uses method distance() of node classes. More...
 
VesselNodegetNode (Vector3 pos)
 Get the node with minimal distance to \cpos. Uses method distance() of node classes. More...
 
const VesselEdgegetEdge (Vector3 pos) const
 Get the edge with minimal distance to \cpos. Uses method distance() of edge classes. More...
 
VesselEdgegetEdge (Vector3 pos)
 Get the edge with minimal distance to \cpos. Uses method distance() of edge classes. More...
 
const VesselNodegetRoot (Vector3 pos) const
 Get the root node with minimal distance to \cpos. More...
 
VesselNodegetRoot (Vector3 pos)
 Get the root node with minimal distance to \cpos. More...
 
const VesselNodegetNode (size_t index) const
 Get node via index position. More...
 
VesselNodegetNode (size_t index)
 Get node via index position. More...
 
const VesselEdgegetEdge (size_t index) const
 Get edge via index position. More...
 
VesselEdgegetEdge (size_t index)
 Get edge via index position. More...
 
const VesselNodegetRoot (size_t index) const
 Get root via index position. More...
 
VesselNodegetRoot (size_t index)
 Get root via index position. More...
 
size_t getIndex (const VesselNode *node) const
 Return the index of VesselNode node in the nodeMap or numNodes() if node was not found. More...
 
size_t getIndex (const VesselEdge *edge) const
 Return the index of VesselEdge edge in the edgeMap or numEdges() if edge was not found. More...
 
Properties

Get access to the GraphPropertyManager for nodes.

PropertyManager::Pointer getNodePropertyManager ()
 
PropertyManager::ConstPointer getNodePropertyManager () const
 
PropertyManager::Pointer getEdgePropertyManager ()
 Get access to the GraphPropertyManager for edges. More...
 
PropertyManager::ConstPointer getEdgePropertyManager () const
 
PropertyManager::Pointer getSkeletonPropertyManager ()
 Get access to the GraphPropertyManager for skeletons. More...
 
PropertyManager::ConstPointer getSkeletonPropertyManager () const
 
World/Voxel Coordinates
void transform (const Matrix4 &m)
 
void setToWorldMatrix (const Matrix4 *m)
 Set the conversion matrix for conversions from voxel to world coordinate. More...
 
void setToWorldMatrix (const Matrix4 &m)
 Set the conversion matrix for conversions from voxel to world coordinate. More...
 
const Matrix4 * getToWorldMatrix () const
 Get the conversion matrix for conversions from voxel to world coordinate. More...
 
void getToWorldMatrix (float *mat) const
 Get the conversion matrix for conversions from voxel to world coordinate. More...
 
Matrix4 getToVoxelMatrix () const
 Get the conversion matrix for conversions from world to voxel coordinate. More...
 
void setToWorld (void)
 Define all element coordinates to be in world coordinates (no conversion takes place). More...
 
void setToVoxel (void)
 Define all element coordinates to be in voxels coordinates (no conversion takes place). More...
 
bool isWorld () const
 Return whether element coordinates are given in voxel or world coordinates. More...
 
void worldVoxelConvert ()
 Convert all graph coordinates from the current coordinate system to the opposite. More...
 
void convertToVoxel (void)
 Convert all coordinates to voxel coordinates. More...
 
void convertToWorld (void)
 Convert all coordinates to world coordinates. More...
 
void setImgExt (ImageVector v)
 
ImageVector getImgExt () const
 
MLint extX () const
 
MLint extY () const
 
MLint extZ () const
 
void setVoxelExt (Vector3 v)
 
Vector3 getVoxelExt () const
 
Assignment
Graphoperator= (const Graph &g)
 Clear current graph and build new one with props of g. More...
 
GraphnewGraph (bool unusedDeprecated=true) const
 Allocate new graph with same properties as this (slowly). More...
 
Basic graph analysis
int separateGraph ()
 Separate graph into clusters of connected edges. More...
 
bool directGraph (double FloodThresh)
 Build a rooted, directed graph. More...
 
void stripCycles ()
 Strip cyclic edges from the graph. More...
 
Geometry
SubImageBoxd getBoundingBox () const
 Calculate graph's bounding box from edge-bounding-boxes. More...
 
Persistence
void addStateToTree (TreeNode *parent) const override
 Overload base-methods: Attaches the object state as children of the given parent node. More...
 
 ML_SET_ADDSTATE_VERSION (3)
 Set current addStateToTree() version number: More...
 
void readStateFromTree (TreeNode *parent) override
 Reads the object state from the children of the given parent node. More...
 
int getVersion (void)
 Get graph's version. More...
 
void setCurrentVersion (void)
 Set graph's version to persistent version number. More...
 
void setVersion (int version)
 Set version. More...
 
bool getUseBinaryPersistence ()
 
void useBinaryPersistence (bool use)
 Set whether to use binary persistence instead of textual representation (text being the default). More...
 
std::string toBinaryData () const
 Returns string containing binary representation of all data necessary to reconstruct the graph. More...
 
void fromBinaryData (const std::string &data)
 Reconstructs the graph using the binary data. More...
 

Protected Member Functions

void _setRootIdToChildren (int rootId, VesselNode *node, VesselEdge *predEdge)
 Sets the given root id to the given node and its child edges and calls itself recursively until the node is a leaf node. More...
 
bool _isContainedInImageExtent (const Vector3 &pos, const Matrix4 &toVoxelMatrix)
 

Static Protected Member Functions

template<typename ResultType , typename ParameterType >
static ResultType getSecond (const ParameterType &p)
 

Protected Attributes

bool _isWorld
 Is the graph in world coordinates? Default is true. More...
 
Matrix4 _toWorldMatrix
 Matrix transform to get from voxel to world coordinates. More...
 
ImageVector _imgExt
 Extension of the image the graph is compiled from. More...
 
Vector3 _voxelExt
 Extension of a voxel of the image the graph is compiled from. More...
 
std::map< MLint, VesselNode * > _nodes
 Maps of graph items. More...
 
std::map< MLint, VesselEdge * > _edges
 
std::map< MLint, VesselNode * > _roots
 
bool _bFlag
 Flag for diverse usage. More...
 
int _numCluster
 Number of non-connected edge-clusters. More...
 

Friends

class GraphAnalyser
 
class SaveTreeData
 
class LoadTreeData
 

Communication

ActionType _action
 
GraphAction_actionCBObject
 
void setAction (ActionType action, std::string sender)
 
ActionType getActionValue (void) const
 
void setActionValue (ActionType action)
 
void setActionCallBack (GraphAction *cbObj)
 

graph labeling (skeleton labels)

min/max values of skeleton labels

static double MIN_SKELETON_LABEL
 
static double MAX_SKELETON_LABEL
 
static double getMinSkeletonLabel (void)
 
static double getMaxSkeletonLabel (void)
 

Detailed Description

Defines the basic Graph class which holds sets of nodes, edges and roots to model tubular structures with graph-like topologies such as vascular systems.

Class Graph is a container of edge and node objects. Edges and nodes may be connected to each other to build up a graph. There may exist several unconnected sub-clusters of connected nodes and edges within the same graph. Edges are not directed a priory. One or more nodes of the graph can be defined as root nodes that are stored by reference as root objects GraphRoot in a separate container of object Graph. Method directGraph( floodThreshold ) is one way to direct the graph according to the currently defined root nodes and edge weights. The directed graph may be called then a forest, i.e. within the Graph object several trees exist, each defined by a root node and directed nodes/edges attached to it.

Important: nodes that are stored in a Graph object may belong logicaly to several trees. For example one node object may be shared by two trees that are connected by this node. Hierarchically the trees are separated when traversing the graph from roots to leaves following the edge directions.

Definition at line 63 of file mlGraph.h.

Member Typedef Documentation

◆ ConstEdgeAccess

typedef boost::function< const VesselEdge* (const EdgeMap::value_type &) > Graph::ConstEdgeAccess

Helper function returning the VesselEdge as const from a key/value pair of a EdgeMap.

Definition at line 196 of file mlGraph.h.

◆ ConstEdgeIterator

typedef boost::transform_iterator<ConstEdgeAccess, EdgeMap::const_iterator> Graph::ConstEdgeIterator

Iterator used to traverse const edges in a edge map (returns data elements of the map instead of tuples).

Definition at line 200 of file mlGraph.h.

◆ ConstNodeAccess

typedef boost::function< const VesselNode* (const NodeMap::value_type &) > Graph::ConstNodeAccess

Helper function returning the VesselNode as const from a key/value pair of a NodeMap.

Definition at line 185 of file mlGraph.h.

◆ ConstNodeIterator

typedef boost::transform_iterator<ConstNodeAccess, NodeMap::const_iterator> Graph::ConstNodeIterator

Iterator used to traverse const nodes in a node map (returns data elements of the map instead of tuples).

Definition at line 189 of file mlGraph.h.

◆ EdgeAccess

typedef boost::function< VesselEdge* (const EdgeMap::value_type &) > Graph::EdgeAccess

Helper function returning the VesselEdge from a key/value pair of a EdgeMap.

Definition at line 194 of file mlGraph.h.

◆ EdgeIterator

typedef boost::transform_iterator<EdgeAccess, EdgeMap::iterator> Graph::EdgeIterator

Iterator used to traverse edges in a edge map (returns data elements of the map instead of tuples).

Definition at line 198 of file mlGraph.h.

◆ EdgeMap

typedef std::map<MLint, VesselEdge*> Graph::EdgeMap

Internal edge storage.

Definition at line 192 of file mlGraph.h.

◆ NodeAccess

typedef boost::function< VesselNode* (const NodeMap::value_type &) > Graph::NodeAccess

Helper function returning the VesselNode from a key/value pair of a NodeMap.

Definition at line 183 of file mlGraph.h.

◆ NodeIterator

typedef boost::transform_iterator<NodeAccess, NodeMap::iterator> Graph::NodeIterator

Iterator used to traverse nodes in a node map (returns data elements of the map instead of tuples).

Definition at line 187 of file mlGraph.h.

◆ NodeMap

typedef std::map<MLint, VesselNode*> Graph::NodeMap

Internal node storage.

Definition at line 181 of file mlGraph.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

Global graph item-type enumeration.

Sometimes used to distinguish different object lookup modes, e.g. when picking elements based on world coordinates.

Enumerator
node 
edge 

Definition at line 73 of file mlGraph.h.

◆ ActionType

Graph modification modes. Ordered from minor to mayor modifications.

Enumerator
NoAction 
LabelGraph 
EditGraph 
ModifyRoots 
ModifyNodesEdges 
NewGraph 
NumActionTypes 

Definition at line 448 of file mlGraph.h.

Constructor & Destructor Documentation

◆ Graph() [1/5]

Graph::Graph ( )

Default constructor.

◆ Graph() [2/5]

Graph::Graph ( const Graph g,
bool  reorder = false 
)

Default copy constructor.

◆ Graph() [3/5]

Graph::Graph ( const Graph g,
const VesselNode root,
bool  reorder = false 
)

Construct graph from tree in g.

◆ Graph() [4/5]

Graph::Graph ( const Graph g,
const std::vector< const VesselNode * > &  roots,
bool  reorder = false 
)

Construct graph from trees in g.

◆ Graph() [5/5]

Graph::Graph ( Graph g,
int  clusterId,
bool  reorder = false 
)

Construct graph from subgraph of g, defined by clusterId in g.

◆ ~Graph()

Graph::~Graph ( )
override

Destructor.

Member Function Documentation

◆ _isContainedInImageExtent()

bool Graph::_isContainedInImageExtent ( const Vector3 &  pos,
const Matrix4 &  toVoxelMatrix 
)
protected

◆ _setRootIdToChildren()

void Graph::_setRootIdToChildren ( int  rootId,
VesselNode node,
VesselEdge predEdge 
)
protected

Sets the given root id to the given node and its child edges and calls itself recursively until the node is a leaf node.

◆ addGraph() [1/2]

void Graph::addGraph ( const Graph g)
inline

Add an entire graph to the current graph.

Definition at line 132 of file mlGraph.h.

◆ addGraph() [2/2]

void Graph::addGraph ( const Graph g,
std::map< const VesselNode *, VesselNode * > &  nodeMapping,
std::map< const VesselEdge *, VesselEdge * > &  edgeMapping,
std::map< const VesselNode *, VesselNode * > &  rootMapping 
)

Add an entire graph to this graph.

If an elements ID is already in use in this graph, a new one will be generated for the copy. The node/edge/rootMappings will contain mappings from old to new IDs upon return.

◆ addStateToTree()

void Graph::addStateToTree ( TreeNode *  parent) const
override

Overload base-methods: Attaches the object state as children of the given parent node.

◆ addSubtrees()

void Graph::addSubtrees ( const std::vector< const VesselNode * > &  roots)

Add subtrees rooted at nodes roots to this graph.

◆ beginEdge() [1/2]

EdgeIterator Graph::beginEdge ( )
inline

Provide iterator access to the begin of the edge map.

Definition at line 218 of file mlGraph.h.

◆ beginEdge() [2/2]

ConstEdgeIterator Graph::beginEdge ( ) const
inline

Provide const iterator access to the begin of the edge map.

Definition at line 223 of file mlGraph.h.

◆ beginNode() [1/2]

NodeIterator Graph::beginNode ( )
inline

Provide iterator access to the begin of the node map.

Definition at line 208 of file mlGraph.h.

◆ beginNode() [2/2]

ConstNodeIterator Graph::beginNode ( ) const
inline

Provide const iterator access to the begin of the node map.

Definition at line 213 of file mlGraph.h.

◆ beginRoot() [1/2]

NodeIterator Graph::beginRoot ( )
inline

Provide iterator access to the begin of the root map.

Definition at line 228 of file mlGraph.h.

◆ beginRoot() [2/2]

ConstNodeIterator Graph::beginRoot ( ) const
inline

Provide const iterator access to the begin of the root map.

Definition at line 233 of file mlGraph.h.

◆ clampToImage()

void Graph::clampToImage ( )

◆ clearGraph()

void Graph::clearGraph ( )

Remove all elements from the graph.

◆ clearRoots()

void Graph::clearRoots ( )

Remove all roots that have been defined.

◆ closeSkeletonGaps()

void Graph::closeSkeletonGaps ( )

Closes gaps in the skeletons between the first or last skeleton of a VesselEdge and the closest node.

Changes eventually the Graph.

◆ convertToVoxel()

void Graph::convertToVoxel ( void  )

Convert all coordinates to voxel coordinates.

Warning: The conversion will be applied even if the coordinates are voxel coordinates already!

◆ convertToWorld()

void Graph::convertToWorld ( void  )

Convert all coordinates to world coordinates.

Warning: The conversion will be applied even if the coordinates are world coordinates already!

◆ copyParts() [1/2]

void Graph::copyParts ( const std::vector< const VesselNode * > &  nodes,
const std::vector< const VesselEdge * > &  edges,
const std::vector< const VesselNode * > &  roots 
)
inline

Copy a collection of nodes, edges and roots from a different graph to this graph.

If an elements ID is already in use, a new ID will be generated for the copy.

Definition at line 149 of file mlGraph.h.

◆ copyParts() [2/2]

void Graph::copyParts ( const std::vector< const VesselNode * > &  nodes,
const std::vector< const VesselEdge * > &  edges,
const std::vector< const VesselNode * > &  roots,
std::map< const VesselNode *, VesselNode * > &  nodeMapping,
std::map< const VesselEdge *, VesselEdge * > &  edgeMapping,
std::map< const VesselNode *, VesselNode * > &  rootMapping 
)

Copy a collection of nodes, edges and roots from a different graph to this graph.

If an elements ID is already in use, a new ID will be generated for the copy. The node/edge/rootMappings will contain mappings from old to new IDs upon return.

◆ createEdge() [1/2]

VesselEdge* Graph::createEdge ( MLint  predNodeId,
MLint  succNodeId,
MLint  useId = -1 
)

Create a VesselEdge with unique id, add it to the Graph and Nodes identified by the respective IDs and return a pointer to it.

◆ createEdge() [2/2]

VesselEdge* Graph::createEdge ( VesselNode predNode,
VesselNode succNode,
MLint  useId = -1 
)

Create a VesselEdge with unique id, add it to the Graph and Nodes and return a pointer to it.

◆ createNode() [1/2]

VesselNode* Graph::createNode ( const ImageVector &  pos,
MLint  useId = -1 
)
inline

Create a VesselNode with unique id, add it to the Graph and return a pointer to it.

Definition at line 118 of file mlGraph.h.

References createNode().

Referenced by createNode().

◆ createNode() [2/2]

VesselNode* Graph::createNode ( const Vector3 &  pos = Vector3(0),
MLint  useId = -1 
)

Create a VesselNode with unique id, add it to the Graph and return a pointer to it.

◆ deepCopy()

Graph* Graph::deepCopy ( ) const
inlineoverride

Implement generic deepCopy functionality using copy constructor.

Definition at line 98 of file mlGraph.h.

◆ directGraph()

bool Graph::directGraph ( double  FloodThresh)

Build a rooted, directed graph.

  • take root nodes from the _roots vector
  • attach edges to the roots in order of their weight( VesselNode::weight , VesselEdge::weight)
  • weight may be set to average minimal radius for an VesselEdge or minimal radius for an VesselNode, for example

WARNING: Graph::directGraph() works for edge and node weights set only. By default all node and edge weights in a graph are set equal to 1.0. To get reasonable flooding results for edge direction, weights has to be set first according to some hierarchy dependent property, e.g. the average minimal distance of an edge. Example:

GraphAnalyser analyzeGraph(this); analyzeGraph.measureAvMinDistance(); for (Graph::EdgeIterator iE = this->beginEdge(); iE != this->endEdge(); ++iE){ dynamic_cast<VesselEdge*>(<em>iE)->weight = dynamic_cast<VesselEdge>(iE)->getAverageMinDistance(); } for (Graph::NodeIterator iN = this->beginNode(); iN != this->endNode(); ++iN){ dynamic_cast<VesselNode>(iN)->weight = dynamic_cast<VesselNode>(*iN)->getMinDistance(); }

◆ endEdge() [1/2]

EdgeIterator Graph::endEdge ( )
inline

Provide iterator access to the end of the edge map.

Definition at line 220 of file mlGraph.h.

◆ endEdge() [2/2]

ConstEdgeIterator Graph::endEdge ( ) const
inline

Provide const iterator access to the end of the edge map.

Definition at line 225 of file mlGraph.h.

◆ endNode() [1/2]

NodeIterator Graph::endNode ( )
inline

Provide iterator access to the end of the node map.

Definition at line 210 of file mlGraph.h.

◆ endNode() [2/2]

ConstNodeIterator Graph::endNode ( ) const
inline

Provide const iterator access to the end of the node map.

Definition at line 215 of file mlGraph.h.

◆ endRoot() [1/2]

NodeIterator Graph::endRoot ( )
inline

Provide iterator access to the end of the root map.

Definition at line 230 of file mlGraph.h.

◆ endRoot() [2/2]

ConstNodeIterator Graph::endRoot ( ) const
inline

Provide const iterator access to the end of the root map.

Definition at line 235 of file mlGraph.h.

◆ extX()

MLint Graph::extX ( ) const
inline

Definition at line 344 of file mlGraph.h.

◆ extY()

MLint Graph::extY ( ) const
inline

Definition at line 345 of file mlGraph.h.

◆ extZ()

MLint Graph::extZ ( ) const
inline

Definition at line 346 of file mlGraph.h.

◆ fromBinaryData()

void Graph::fromBinaryData ( const std::string &  data)

Reconstructs the graph using the binary data.

◆ getActionValue()

ActionType Graph::getActionValue ( void  ) const

◆ getBoundingBox()

SubImageBoxd Graph::getBoundingBox ( ) const

Calculate graph's bounding box from edge-bounding-boxes.

◆ getEdge() [1/4]

VesselEdge* Graph::getEdge ( size_t  index)

Get edge via index position.

Deprecated:
WARNING: This method is deprecated and slow! Please adapt your code to not use it.

◆ getEdge() [2/4]

const VesselEdge* Graph::getEdge ( size_t  index) const

Get edge via index position.

Deprecated:
WARNING: This method is deprecated and slow! Please adapt your code to not use it.

◆ getEdge() [3/4]

VesselEdge* Graph::getEdge ( Vector3  pos)

Get the edge with minimal distance to \cpos. Uses method distance() of edge classes.

◆ getEdge() [4/4]

const VesselEdge* Graph::getEdge ( Vector3  pos) const

Get the edge with minimal distance to \cpos. Uses method distance() of edge classes.

◆ getEdgePropertyManager() [1/2]

PropertyManager::Pointer Graph::getEdgePropertyManager ( )
inline

Get access to the GraphPropertyManager for edges.

Definition at line 301 of file mlGraph.h.

◆ getEdgePropertyManager() [2/2]

PropertyManager::ConstPointer Graph::getEdgePropertyManager ( ) const
inline

Definition at line 302 of file mlGraph.h.

◆ getFlag()

bool Graph::getFlag ( ) const
inline

Definition at line 460 of file mlGraph.h.

◆ getIdEdge() [1/2]

VesselEdge* Graph::getIdEdge ( MLint  id)

Get edge with id id.

◆ getIdEdge() [2/2]

const VesselEdge* Graph::getIdEdge ( MLint  id) const

Get edge with id id.

◆ getIdNode() [1/2]

VesselNode* Graph::getIdNode ( MLint  id)

Get node with id id;.

◆ getIdNode() [2/2]

const VesselNode* Graph::getIdNode ( MLint  id) const

Get node with id id;.

◆ getImgExt()

ImageVector Graph::getImgExt ( ) const
inline

Definition at line 343 of file mlGraph.h.

◆ getIndex() [1/2]

size_t Graph::getIndex ( const VesselEdge edge) const

Return the index of VesselEdge edge in the edgeMap or numEdges() if edge was not found.

◆ getIndex() [2/2]

size_t Graph::getIndex ( const VesselNode node) const

Return the index of VesselNode node in the nodeMap or numNodes() if node was not found.

◆ getMaxSkeletonLabel()

static double Graph::getMaxSkeletonLabel ( void  )
inlinestatic

Definition at line 530 of file mlGraph.h.

◆ getMinSkeletonLabel()

static double Graph::getMinSkeletonLabel ( void  )
inlinestatic

Definition at line 529 of file mlGraph.h.

◆ getNode() [1/4]

VesselNode* Graph::getNode ( size_t  index)

Get node via index position.

Deprecated:
WARNING: This method is deprecated and slow! Please adapt your code to not use it.

◆ getNode() [2/4]

const VesselNode* Graph::getNode ( size_t  index) const

Get node via index position.

Deprecated:
WARNING: This method is deprecated and slow! Please adapt your code to not use it.

◆ getNode() [3/4]

VesselNode* Graph::getNode ( Vector3  pos)

Get the node with minimal distance to \cpos. Uses method distance() of node classes.

◆ getNode() [4/4]

const VesselNode* Graph::getNode ( Vector3  pos) const

Get the node with minimal distance to \cpos. Uses method distance() of node classes.

◆ getNodePropertyManager() [1/2]

PropertyManager::Pointer Graph::getNodePropertyManager ( )
inline

Definition at line 297 of file mlGraph.h.

◆ getNodePropertyManager() [2/2]

PropertyManager::ConstPointer Graph::getNodePropertyManager ( ) const
inline

Definition at line 298 of file mlGraph.h.

◆ getNumCluster()

int Graph::getNumCluster ( ) const
inline

Definition at line 458 of file mlGraph.h.

◆ getRoot() [1/4]

VesselNode* Graph::getRoot ( size_t  index)

Get root via index position.

Deprecated:
WARNING: This method is deprecated and slow! Please adapt your code to not use it.

◆ getRoot() [2/4]

const VesselNode* Graph::getRoot ( size_t  index) const

Get root via index position.

Deprecated:
WARNING: This method is deprecated and slow! Please adapt your code to not use it.

◆ getRoot() [3/4]

VesselNode* Graph::getRoot ( Vector3  pos)

Get the root node with minimal distance to \cpos.

◆ getRoot() [4/4]

const VesselNode* Graph::getRoot ( Vector3  pos) const

Get the root node with minimal distance to \cpos.

◆ getSecond()

template<typename ResultType , typename ParameterType >
static ResultType Graph::getSecond ( const ParameterType &  p)
inlinestaticprotected

Definition at line 416 of file mlGraph.h.

◆ getSkeletonPropertyManager() [1/2]

PropertyManager::Pointer Graph::getSkeletonPropertyManager ( )
inline

Get access to the GraphPropertyManager for skeletons.

Definition at line 305 of file mlGraph.h.

◆ getSkeletonPropertyManager() [2/2]

PropertyManager::ConstPointer Graph::getSkeletonPropertyManager ( ) const
inline

Definition at line 306 of file mlGraph.h.

◆ getToVoxelMatrix()

Matrix4 Graph::getToVoxelMatrix ( ) const

Get the conversion matrix for conversions from world to voxel coordinate.

◆ getToWorldMatrix() [1/2]

const Matrix4* Graph::getToWorldMatrix ( ) const

Get the conversion matrix for conversions from voxel to world coordinate.

◆ getToWorldMatrix() [2/2]

void Graph::getToWorldMatrix ( float *  mat) const

Get the conversion matrix for conversions from voxel to world coordinate.

◆ getUseBinaryPersistence()

bool Graph::getUseBinaryPersistence ( )
inline

Definition at line 490 of file mlGraph.h.

◆ getVersion()

int Graph::getVersion ( void  )
inline

Get graph's version.

differs from value getAddStateVersion() if graph is restored from older state and not set by setVersion().

Definition at line 483 of file mlGraph.h.

◆ getVoxelExt()

Vector3 Graph::getVoxelExt ( ) const
inline

Definition at line 349 of file mlGraph.h.

◆ insertRoot()

void Graph::insertRoot ( VesselNode node)

Insert a node to the list of root nodes.

◆ isWorld()

bool Graph::isWorld ( ) const
inline

Return whether element coordinates are given in voxel or world coordinates.

Definition at line 331 of file mlGraph.h.

◆ mergeEdges()

bool Graph::mergeEdges ( VesselEdge parent,
VesselEdge child 
)

◆ ML_SET_ADDSTATE_VERSION()

Graph::ML_SET_ADDSTATE_VERSION ( )

Set current addStateToTree() version number:

◆ newGraph()

Graph* Graph::newGraph ( bool  unusedDeprecated = true) const

Allocate new graph with same properties as this (slowly).

◆ numEdges()

size_t Graph::numEdges ( ) const
inline

Returns the number edges in this graph.

Definition at line 240 of file mlGraph.h.

◆ numNodes()

size_t Graph::numNodes ( ) const
inline

Returns the number nodes in this graph.

Definition at line 238 of file mlGraph.h.

◆ numRoots()

size_t Graph::numRoots ( ) const
inline

Returns the number roots in this graph.

Definition at line 242 of file mlGraph.h.

◆ operator=()

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

Clear current graph and build new one with props of g.

◆ purifyGraph()

void Graph::purifyGraph ( )

Removes orphan nodes and unsets false cyclic edges (edges with a leaf node that are marked as cyclic).

Also, all the nodes' and edges' ids are set anew. Remove roots that have no succeeding edges, i.e. all edges are attached to other root nodes

◆ readStateFromTree()

void Graph::readStateFromTree ( TreeNode *  parent)
override

Reads the object state from the children of the given parent node.

◆ removeEdge()

bool Graph::removeEdge ( VesselEdge edge,
bool  removeEmptyNodes = true 
)

Remove an edge from the graph.

◆ removeNode()

bool Graph::removeNode ( VesselNode node)

Remove a node from the graph.

◆ removeOrphanNodes()

void Graph::removeOrphanNodes ( )

Remove nodes with no edges attached.

◆ removeRoot()

void Graph::removeRoot ( VesselNode r)

Remove a root from the graph.

◆ separateGraph()

int Graph::separateGraph ( )

Separate graph into clusters of connected edges.

Edges belonging to the same cluster are labeled with ascending cluster-label.

◆ setAction()

void Graph::setAction ( ActionType  action,
std::string  sender 
)

◆ setActionCallBack()

void Graph::setActionCallBack ( GraphAction cbObj)

◆ setActionValue()

void Graph::setActionValue ( ActionType  action)

◆ setCurrentVersion()

void Graph::setCurrentVersion ( void  )
inline

Set graph's version to persistent version number.

Definition at line 485 of file mlGraph.h.

◆ setFlag()

void Graph::setFlag ( bool  bFlag)
inline

Definition at line 461 of file mlGraph.h.

◆ setImgExt()

void Graph::setImgExt ( ImageVector  v)
inline

Definition at line 342 of file mlGraph.h.

◆ setRootIdToAllChildren()

void Graph::setRootIdToAllChildren ( )

Descends recursively from all roots to the leaves in the trees and sets the rootId of the according root to all child items (edges and nodes).

◆ setToVoxel()

void Graph::setToVoxel ( void  )
inline

Define all element coordinates to be in voxels coordinates (no conversion takes place).

Definition at line 329 of file mlGraph.h.

◆ setToWorld()

void Graph::setToWorld ( void  )
inline

Define all element coordinates to be in world coordinates (no conversion takes place).

Definition at line 327 of file mlGraph.h.

◆ setToWorldMatrix() [1/2]

void Graph::setToWorldMatrix ( const Matrix4 &  m)

Set the conversion matrix for conversions from voxel to world coordinate.

◆ setToWorldMatrix() [2/2]

void Graph::setToWorldMatrix ( const Matrix4 *  m)

Set the conversion matrix for conversions from voxel to world coordinate.

◆ setVersion()

void Graph::setVersion ( int  version)
inline

Set version.

Definition at line 487 of file mlGraph.h.

◆ setVoxelExt()

void Graph::setVoxelExt ( Vector3  v)
inline

Definition at line 348 of file mlGraph.h.

◆ splitEdge()

MLint Graph::splitEdge ( MLint  edgeID,
size_t  skeletonIndex 
)

Splits edge with id edgeID at skeleton index skeletonIndex and returns the ID of the additionally created edge.

If the edge could not be split (e.g. edgeID not found, no vessel edge or not enough skeletons), -1 is returned.

◆ stripCycles()

void Graph::stripCycles ( )

Strip cyclic edges from the graph.

All cyclic edges are removed to build a graph without cycles. This only works correctly if the graph has been directed with directGraph() first.

◆ toBinaryData()

std::string Graph::toBinaryData ( ) const

Returns string containing binary representation of all data necessary to reconstruct the graph.

◆ transform()

void Graph::transform ( const Matrix4 &  m)

◆ useBinaryPersistence()

void Graph::useBinaryPersistence ( bool  use)
inline

Set whether to use binary persistence instead of textual representation (text being the default).

Note
Binary persistence uses Boost serialization, which from time to time is updated in an incompatible way (can load files from older Boost versions, but not newer), so older MeVisLab versions may not be able to load graph files generated by newer MeVisLab versions if utilizing binary persistence.

Definition at line 496 of file mlGraph.h.

◆ worldVoxelConvert()

void Graph::worldVoxelConvert ( )

Convert all graph coordinates from the current coordinate system to the opposite.

Friends And Related Function Documentation

◆ GraphAnalyser

friend class GraphAnalyser
friend

Definition at line 66 of file mlGraph.h.

◆ LoadTreeData

friend class LoadTreeData
friend

Definition at line 68 of file mlGraph.h.

◆ SaveTreeData

friend class SaveTreeData
friend

Definition at line 67 of file mlGraph.h.

Member Data Documentation

◆ _action

ActionType Graph::_action
protected

Definition at line 550 of file mlGraph.h.

◆ _actionCBObject

GraphAction* Graph::_actionCBObject
protected

Definition at line 551 of file mlGraph.h.

◆ _bFlag

bool Graph::_bFlag
protected

Flag for diverse usage.

Definition at line 539 of file mlGraph.h.

◆ _edges

std::map<MLint, VesselEdge*> Graph::_edges
protected

Definition at line 429 of file mlGraph.h.

◆ _imgExt

ImageVector Graph::_imgExt
protected

Extension of the image the graph is compiled from.

Definition at line 423 of file mlGraph.h.

◆ _isWorld

bool Graph::_isWorld
protected

Is the graph in world coordinates? Default is true.

Definition at line 419 of file mlGraph.h.

◆ _nodes

std::map<MLint, VesselNode*> Graph::_nodes
protected

Maps of graph items.

Definition at line 428 of file mlGraph.h.

◆ _numCluster

int Graph::_numCluster
protected

Number of non-connected edge-clusters.

Default is -1 (not analyzed this feature yet). Is determined by method separateGraph() .

Definition at line 543 of file mlGraph.h.

◆ _roots

std::map<MLint, VesselNode*> Graph::_roots
protected

Definition at line 430 of file mlGraph.h.

◆ _toWorldMatrix

Matrix4 Graph::_toWorldMatrix
protected

Matrix transform to get from voxel to world coordinates.

Definition at line 421 of file mlGraph.h.

◆ _voxelExt

Vector3 Graph::_voxelExt
protected

Extension of a voxel of the image the graph is compiled from.

Definition at line 425 of file mlGraph.h.

◆ MAX_SKELETON_LABEL

double Graph::MAX_SKELETON_LABEL
staticprotected

Definition at line 563 of file mlGraph.h.

◆ MIN_SKELETON_LABEL

double Graph::MIN_SKELETON_LABEL
staticprotected

Definition at line 562 of file mlGraph.h.


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