20 #include <boost/graph/dijkstra_shortest_paths.hpp>
25 : m_Mode( UnweightedUndirectedMode )
26 , m_EverythingConnected( true )
52 case UnweightedUndirectedMode:
54 CalculateUnweightedUndirectedShortestPaths( boostGraph );
57 case WeightedUndirectedMode:
59 CalculateWeightedUndirectedShortestPaths( boostGraph );
64 ConvertDistanceMapToHistogram();
69 std::vector< DescriptorType > predecessorMap( boost::num_vertices( *boostGraph ) );
70 int numberOfNodes( boost::num_vertices( *boostGraph ) );
72 m_DistanceMatrix.resize( numberOfNodes );
73 for(
unsigned int index(0); index < m_DistanceMatrix.size(); index++ )
75 m_DistanceMatrix[ index ].resize( numberOfNodes );
79 boost::tie(iterator, end) = boost::vertices( *boostGraph );
81 for (
int index(0) ; iterator != end; ++iterator, index++)
98 int numberOfNodes( m_DistanceMatrix.size() );
99 m_EverythingConnected =
true;
101 for(
unsigned int index(0); index < m_DistanceMatrix.size(); index++ )
103 for(
unsigned int innerIndex(0); innerIndex < m_DistanceMatrix[ index ].size(); innerIndex++ )
105 if( m_DistanceMatrix[ index ][ innerIndex ] > longestPath )
107 if( m_DistanceMatrix[ index ][ innerIndex ] < numberOfNodes )
109 longestPath = m_DistanceMatrix[ index ][ innerIndex ];
114 m_EverythingConnected =
false;
120 m_HistogramVector.resize( longestPath + 1 );
122 for(
unsigned int index(0); index < m_DistanceMatrix.size(); index++ )
124 for(
unsigned int innerIndex(0); innerIndex < m_DistanceMatrix[ index ].size(); innerIndex++ )
126 if( m_DistanceMatrix[ index ][ innerIndex ] < numberOfNodes )
128 m_HistogramVector[ m_DistanceMatrix[ index ][ innerIndex ] ]++;
135 for(
unsigned int index(1); index < m_HistogramVector.size(); index++ )
137 m_HistogramVector[ index ] = m_HistogramVector[ index ] / 2;
141 if( m_HistogramVector[ 0 ] >= numberOfNodes )
143 m_HistogramVector[ 0 ] = m_HistogramVector[ 0 ] - numberOfNodes;
152 this->m_Valid =
true;
163 if( !m_EverythingConnected )
169 double efficiency( 0.0 );
171 double overallDistance( 0.0 );
172 double numberOfPairs( 0.0 );
174 for(
unsigned int index(0); index < m_HistogramVector.size(); index++ )
176 overallDistance = overallDistance + m_HistogramVector[ index ] * index;
177 numberOfPairs = numberOfPairs + m_HistogramVector[ index ];
181 efficiency = numberOfPairs / overallDistance;
ShortestPathCalculationMode
void CalculateWeightedUndirectedShortestPaths(NetworkType *boostGraph)
boost::graph_traits< NetworkType >::vertex_iterator IteratorType
static const char * CONNECTOMICS_WARNING_NETWORK_DISCONNECTED
static const char * CONNECTOMICS_WARNING_CAN_NOT_COMPUTE_EFFICIENCY
mitk::ConnectomicsNetwork::NetworkType NetworkType
ConnectomicsShortestPathHistogram()
void CalculateUnweightedUndirectedShortestPaths(NetworkType *boostGraph)
void ConvertDistanceMapToHistogram()
#define MBI_INFO
Macros for different message levels. Creates an instance of class PseudoStream with the corresponding...
virtual ~ConnectomicsShortestPathHistogram()
void SetShortestPathCalculationMode(const ShortestPathCalculationMode &)
ShortestPathCalculationMode GetShortestPathCalculationMode()
virtual void ComputeFromConnectomicsNetwork(ConnectomicsNetwork *source) override
Creates a new histogram from the network source.
static const char * CONNECTOMICS_WARNING_UNIMPLEMENTED_FEATURE
static const char * CONNECTOMICS_WARNING_ZERO_DISTANCE_NODES
static const char * CONNECTOMICS_WARNING_NETWORK_NOT_VALID
Connectomics Network Class.
NetworkType * GetBoostGraph()
std::string m_Subject
Subject of the histogram as a string.