void mitk::ConnectomicsSimulatedAnnealingPermutationModularity::extractModuleSubgraph( ToModuleMapType *vertexToModuleMap, mitk::ConnectomicsNetwork::Pointer network, int moduleToSplit, mitk::ConnectomicsNetwork::Pointer subNetwork, VertexToVertexMapType* graphToSubgraphVertexMap, VertexToVertexMapType* subgraphToGraphVertexMap ) { const std::vector< VertexDescriptorType > allNodesVector = network->GetVectorOfAllVertexDescriptors(); // add vertices to subgraph for( unsigned int nodeNumber( 0 ); nodeNumber < allNodesVector.size() ; nodeNumber++) { if( moduleToSplit == vertexToModuleMap->find( allNodesVector[ nodeNumber ] )->second ) { int id = network->GetNode( allNodesVector[ nodeNumber ] ).id; VertexDescriptorType newVertex = subNetwork->AddVertex( id ); graphToSubgraphVertexMap->insert( std::pair<VertexDescriptorType, VertexDescriptorType>( allNodesVector[ nodeNumber ], newVertex ) ); subgraphToGraphVertexMap->insert( std::pair<VertexDescriptorType, VertexDescriptorType>( newVertex, allNodesVector[ nodeNumber ] ) ); } } // add edges to subgraph VertexToVertexMapType::iterator iter = graphToSubgraphVertexMap->begin(); VertexToVertexMapType::iterator end = graphToSubgraphVertexMap->end(); while( iter != end ) { const std::vector< VertexDescriptorType > adjacentNodexVector = network->GetVectorOfAdjacentNodes( iter->first ); for( unsigned int adjacentNodeNumber( 0 ); adjacentNodeNumber < adjacentNodexVector.size() ; adjacentNodeNumber++) { // if the adjacent vertex is part of the subgraph, // add edge, if it does not exist yet, else do nothing VertexDescriptorType adjacentVertex = adjacentNodexVector[ adjacentNodeNumber ]; if( graphToSubgraphVertexMap->count( adjacentVertex ) > 0 ) { if( !subNetwork->EdgeExists( iter->second, graphToSubgraphVertexMap->find( adjacentVertex )->second ) ) { //edge exists in parent network, but not yet in sub network const VertexDescriptorType vertexA = iter->second; const VertexDescriptorType vertexB = graphToSubgraphVertexMap->find( adjacentVertex )->second; const int sourceID = network->GetNode( vertexA ).id; const int targetID = network->GetNode( vertexB ).id; const int weight = network->GetEdge( iter->first, graphToSubgraphVertexMap->find( adjacentVertex )->first ).weight; subNetwork->AddEdge( vertexA , vertexB, sourceID, targetID, weight ); } } } iter++; }// end while( iter != end ) }