예제 #1
0
void OnlyD3CEdgesNoBack(PNGraph& dir_graph, PNGraph& d3c_graph) {
    // Add all of the nodes into the new graph
    for (TNGraph::TNodeI node = dir_graph->BegNI(); node < dir_graph->EndNI();
         node++) {
        int curr_node = node.GetId();
        d3c_graph->AddNode(curr_node);
    }
    for (TNGraph::TNodeI node = dir_graph->BegNI(); node < dir_graph->EndNI();
         node++) {
        int curr_node = node.GetId();
        auto curr_node_it = dir_graph->GetNI(curr_node);
        for (int out_edge = 0; out_edge < curr_node_it.GetOutDeg(); ++out_edge) {
            int out_node = curr_node_it.GetOutNId(out_edge);
            for (int in_edge = 0; in_edge < curr_node_it.GetInDeg(); ++in_edge) {
                int in_node = curr_node_it.GetInNId(in_edge);
                if (dir_graph->IsEdge(out_node, in_node) && out_node != in_node) {
		    if (!d3c_graph->IsEdge(in_node, out_node) &&
			!d3c_graph->IsEdge(curr_node, in_node) &&
			!d3c_graph->IsEdge(out_node, curr_node)) {
			if (!d3c_graph->IsEdge(out_node, in_node)) { d3c_graph->AddEdge(out_node, in_node); }
			if (!d3c_graph->IsEdge(in_node, curr_node)) { d3c_graph->AddEdge(in_node, curr_node); }
			if (!d3c_graph->IsEdge(curr_node, out_node)) { d3c_graph->AddEdge(curr_node, out_node); }
		    }
                }
            }
        }
    }
}
예제 #2
0
void OnlyD3CEdges(PNGraph& dir_graph, PNGraph& d3c_graph, bool recip_edges) {
    // Add all of the nodes into the new graph
    for (TNGraph::TNodeI node = dir_graph->BegNI(); node < dir_graph->EndNI();
         node++) {
        int curr_node = node.GetId();
        d3c_graph->AddNode(curr_node);
    }
    for (TNGraph::TNodeI node = dir_graph->BegNI(); node < dir_graph->EndNI();
         node++) {
        int curr_node = node.GetId();
        auto curr_node_it = dir_graph->GetNI(curr_node);
        for (int out_edge = 0; out_edge < curr_node_it.GetOutDeg(); ++out_edge) {
            int out_node = curr_node_it.GetOutNId(out_edge);
            for (int in_edge = 0; in_edge < curr_node_it.GetInDeg(); ++in_edge) {
                int in_node = curr_node_it.GetInNId(in_edge);
		if (out_node == in_node && !recip_edges) { continue; }
                if (dir_graph->IsEdge(out_node, in_node) || recip_edges) {
                    if (!d3c_graph->IsEdge(out_node, in_node)) {
			d3c_graph->AddEdge(out_node, in_node);
		    }
                    if (!d3c_graph->IsEdge(in_node, curr_node)) {
			d3c_graph->AddEdge(in_node, curr_node);
		    }
                    if (!d3c_graph->IsEdge(curr_node, out_node)) {
			d3c_graph->AddEdge(curr_node, out_node);
		    }
                }
            }
        }
    }
#ifdef _VERBOSE_
    std::cout << "Original graph edge count: " << dir_graph->GetEdges() << std::endl
	      << "D3C graph edge count: " << d3c_graph->GetEdges() << std::endl;
#endif
}
예제 #3
0
파일: vms.cpp 프로젝트: Lemma1/MINAMI
int MNM_Link_Vms::hook_link(PNEGraph graph)
{
  auto _node_it = graph -> GetNI(graph -> GetEI(m_my_link_ID).GetSrcNId());
  for (int e = 0; e < _node_it.GetOutDeg(); ++e) {
    m_out_link_vec.push_back(_node_it.GetOutEId(e));
    std::vector<MNM_Path*> *_v = new std::vector<MNM_Path*>();
    m_link_path_map.insert(std::pair<TInt, std::vector<MNM_Path*>*>(_node_it.GetOutEId(e), _v));
  }
  return 0;
}