17 std::pair<VertexDescriptorType, VertexDescriptorType>(boost::graph_traits<GraphType>::null_vertex(),
18 boost::graph_traits<GraphType>::null_vertex());
35 std::vector<TubeDescriptorType> shortestPath;
45 typedef std::map<VertexDescriptorType, EdgeDescriptorType> EdgeMap;
46 typedef boost::associative_property_map<EdgeMap> PredecessorMap;
47 typedef boost::edge_predecessor_recorder<PredecessorMap, boost::on_tree_edge> PredecessorVisitor;
48 typedef boost::dfs_visitor<std::pair<PredecessorVisitor, boost::null_visitor>> DFSVisitor;
51 PredecessorMap predecessorMap(edgesMap);
53 PredecessorVisitor predecessorVisitor(predecessorMap);
54 boost::null_visitor nullVisitor;
55 DFSVisitor visitor = boost::make_dfs_visitor(std::make_pair(predecessorVisitor, nullVisitor));
57 std::map<VertexDescriptorType, boost::default_color_type> vertexColorMap;
58 std::map<EdgeDescriptorType, boost::default_color_type> edgeColorMap;
60 boost::undirected_dfs(
61 m_Graph, visitor, make_assoc_property_map(vertexColorMap), make_assoc_property_map(edgeColorMap), startTube.second);
63 std::vector<TubeDescriptorType> solutionPath;
64 solutionPath.push_back(endTube);
68 MITK_INFO <<
"Source: [" << startTube.first <<
"," << startTube.second <<
"] Target: [" << endTube.first <<
"," 69 << endTube.second <<
"]";
70 MITK_INFO <<
"tube [" << endTube.first <<
"," << endTube.second <<
"]";
73 if (pathEdgeSource == 10393696)
76 pathEdgeSource = boost::source(edge,
m_Graph);
77 pathEdgeTarget = boost::target(edge,
m_Graph);
79 MITK_INFO <<
"tube [" << tube.first <<
"," << tube.second <<
"]";
80 solutionPath.push_back(tube);
81 }
while (pathEdgeSource != startTube.second);
89 std::vector<mitk::TubeGraph::TubeDescriptorType> pathToPeriphery;
94 if (m_Root == m_RootTube.first)
95 m_Root = m_RootTube.second;
97 m_Root = m_RootTube.first;
105 pathToPeriphery.push_back(startTube);
106 this->GetOutEdgesOfAVertex(startTube.second, directedGraph, pathToPeriphery);
108 return pathToPeriphery;
113 std::vector<mitk::TubeGraph::TubeDescriptorType> &pathToPeriphery)
116 std::pair<OutEdgeIteratorType, OutEdgeIteratorType> outEdges = boost::out_edges(vertex, directedGraph);
117 for (; outEdges.first != outEdges.second; ++outEdges.first)
120 tube.first = boost::source(*outEdges.first, directedGraph);
121 tube.second = boost::target(*outEdges.first, directedGraph);
123 if (std::find(pathToPeriphery.begin(), pathToPeriphery.end(), tube) == pathToPeriphery.end())
125 pathToPeriphery.push_back(tube);
126 this->GetOutEdgesOfAVertex(tube.second, directedGraph, pathToPeriphery);
134 float tubeDiameter = 0.0;
138 boost::tie(iterator, end) = boost::edges(
m_Graph);
140 for (; iterator != end; ++iterator)
144 std::pair<TubeGraphVertex, TubeGraphVertex> soureTargetPair = this->
GetVerticesOfAnEdge(*iterator);
147 if (tempDiameter > tubeDiameter)
149 tubeDiameter = tempDiameter;
161 boost::breadth_first_search(
m_Graph, startVertex, visitor(vis));
162 return directedGraph;
169 std::map<VertexDescriptorType, VertexDescriptorType> vertexDescriptorOldToNewMap;
172 for (
auto it = subGraphTubes.begin(); it != subGraphTubes.end(); it++)
175 if (vertexDescriptorOldToNewMap.find(it->first) == vertexDescriptorOldToNewMap.end())
180 vertexDescriptorOldToNewMap.insert(
181 std::pair<VertexDescriptorType, VertexDescriptorType>(it->first, newVertexDescriptor));
184 if (vertexDescriptorOldToNewMap.find(it->second) == vertexDescriptorOldToNewMap.end())
187 vertexDescriptorOldToNewMap.insert(
188 std::pair<VertexDescriptorType, VertexDescriptorType>(it->second, newVertexDescriptor));
203 subGraph->AddEdge(sourceVertex, targetVertex, this->
GetEdge(edgeDescriptor));
205 subGraph->CopyInformation(
this);
208 geometry->Initialize();
209 subGraph->SetGeometry(geometry);
218 for (
auto it = deletedTubes.begin(); it != deletedTubes.end(); it++)
243 if (m_Root == root.first)
244 m_Root = root.second;
boost::adjacency_list< boost::vecS, boost::vecS, boost::directedS > DirectedGraphType
EdgeDescriptorType GetEdgeDescriptorByVerices(const VertexDescriptorType &vertexA, const VertexDescriptorType &vertexB) const
static const TubeDescriptorType ErrorId
void RemoveSubGraph(std::vector< TubeDescriptorType > deletedTubes)
void RemoveVertex(const VertexDescriptorType &vertex)
Base Class for Tube Graphs.
Base Class for Tube Graph Vertices.
VertexDescriptorType GetVertexDescriptor(const VertexType &vertexData) const
VertexType GetVertex(const VertexDescriptorType &vertex)
void SetRoot(const VertexDescriptorType &root)
std::vector< TubeDescriptorType > SearchAllPathBetweenVertices(const TubeDescriptorType &startTube, const TubeDescriptorType &endTube)
std::vector< EdgeType > GetAllEdgesOfAVertex(const VertexDescriptorType &vertex) const
float GetEdgeAverageDiameter(TubeGraphVertex &source, TubeGraphVertex &target)
std::vector< TubeDescriptorType > SearchPathToPeriphery(const TubeDescriptorType &startTube)
void RemoveEdge(const EdgeDescriptorType &edge)
boost::graph_traits< GraphType >::edge_descriptor EdgeDescriptorType
std::pair< VertexDescriptorType, VertexDescriptorType > TubeDescriptorType
TubeGraph::Pointer CreateSubGraph(std::vector< TubeDescriptorType > subGraphTubes)
EdgeType GetEdge(const EdgeDescriptorType &edge)
TubeDescriptorType GetThickestTube()
boost::graph_traits< GraphType >::edge_iterator EdgeIteratorType
boost::graph_traits< GraphType >::out_edge_iterator OutEdgeIteratorType
TubeDescriptorType GetRootTube()
Base Class for Tube Graph Edges.
std::pair< VertexType, VertexType > GetVerticesOfAnEdge(const EdgeDescriptorType &edge) const
DirectedGraphType GetDirectedGraph(VertexDescriptorType startVertex)
Template class for undirected graphs.Paramters should be the vertex and edge classes, which contains the information.
boost::graph_traits< GraphType >::vertex_descriptor VertexDescriptorType
UndirectedGraph< VertexType, EdgeType > & operator=(const UndirectedGraph< VertexType, EdgeType > &rhs)
std::vector< TubeDescriptorType > SearchShortestPath(const TubeDescriptorType &startTube, const TubeDescriptorType &endTube)
void SetRootTube(const TubeDescriptorType &root)
VertexDescriptorType GetRootVertex()
TubeGraph & operator=(const TubeGraph &rhs)