当前位置: 首页>>代码示例>>C++>>正文


C++ Graph::BeginEdges方法代码示例

本文整理汇总了C++中Graph::BeginEdges方法的典型用法代码示例。如果您正苦于以下问题:C++ Graph::BeginEdges方法的具体用法?C++ Graph::BeginEdges怎么用?C++ Graph::BeginEdges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graph的用法示例。


在下文中一共展示了Graph::BeginEdges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: FindMaximalMatching

        void AlgorithmMAXIMALMATCHING::FindMaximalMatching(Graph& G, EdgeSet& Matching, VertexSet& MatchedVertices)
        {
            for(EdgeIterator e = G.BeginEdges(); e != G.EndEdges(); e++)
            {
                VertexSet Incident = (*e)->CollectIncidentVertices(1,1,1);
                if(SetHelper::IntersectionEmpty(MatchedVertices,Incident))
                {
                    Matching.insert(*e);
                    SetHelper::DestructiveUnion(MatchedVertices, Incident);
                }
            }

        }
开发者ID:OpenGraphtheory,项目名称:OpenGraphtheory,代码行数:13,代码来源:maximalmatching.cpp

示例2: Export

        void ExportFilterRGML::Export(Graph& G, ostream& os, VertexColoring& vertexcoloring,
                                      EdgeColoring& edgecoloring, float dpi, float edgewidth, float vertexradius)
        {
            StringTranslatorXML Translator;

            os << "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
            os << "<!-- www.Open-Graphtheory.org -->\n\n";

            os << "<rdf:RDF\n"
               << "  xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\n"
               << "  xmlns=\"http://purl.org/puninj/2001/05/rgml-schema#\"\n"
               << "  xmlns:rgml=\"http://purl.org/puninj/2001/05/rgml-schema#\"\n"
               << ">\n\n";

            os << "  <Graph rdf:ID=\"graph\" rgml:directed=\"false\">\n";

            /// declare vertices
            os << "    <nodes>\n";
            os << "      <rdf:Bag>\n";
            for(VertexIterator v = G.BeginVertices(); v != G.EndVertices(); v++)
                os << "        <rdf:li rdf:resource=\"#n" << (*v)->GetID() << "\"/>\n";
            os << "      </rdf:Bag>\n";
            os << "    </nodes>\n\n";

            /// declare edges and arcs
            os << "    <edges>\n";
            os << "      <rdf:Bag>\n";
            for(EdgeIterator e = G.BeginEdges(); e != G.EndEdges(); e++)
                os << "        <rdf:li rdf:resource=\"#e" << (*e)->GetID() << "\"/>\n";
            os << "      </rdf:Bag>\n";
            os << "    </edges>\n";

            os << "  </Graph>\n\n";

            /// write vertices
            for(VertexIterator v = G.BeginVertices(); v != G.EndVertices(); v++)
                os << "  <Node rdf:ID=\"n" << (*v)->GetID() << "\" rgml:label=\"" << Translator.Translate((*v)->GetLabel()) << "\"/>\n";

            /// write edges
            for(EdgeIterator ei = G.BeginEdges(); ei != G.EndEdges(); ei++)
            {
                Edge* e = *ei;
                if(e->IsHyperedge())
                    continue;
                os << "\n  <Edge rdf:ID=\"e" << e->GetID() << "\" directed=\"" << (e->IsEdge()?"false":"true") << "\""
                   << " rgml:label=\"" << Translator.Translate(e->GetLabel()) << "\">\n";
                os << "    <source rdf:resource=\"#n" << e->From()->GetID() << "\"/>\n";
                os << "    <target rdf:resource=\"#n" << e->To()->GetID() << "\"/>\n";
                os << "  </Edge>\n";
            }

            /// write hyperedges
            for(EdgeIterator ei = G.BeginEdges(); ei != G.EndEdges(); ei++)
            {
                Edge *e = *ei;
                if(!e->IsHyperedge())
                    continue;
                os << "\n  <Edge rdf:ID=\"e" << e->GetID() << "\""
                   << " rgml:label=\"" << Translator.Translate(e->GetLabel()) << "\">\n";
                os << "    <nodes>\n";
                os << "      <rdf:Seq>\n";
                for(VertexEdgeConnectionIterator conn = e->BeginConnections(); conn != e->EndConnections(); conn++)
                    os << "        <rdf:li rdf:resource=\"#n" << (*conn)->GetVertex()->GetID() << "\"/>\n";
                os << "      </rdf:Seq>\n";
                os << "    </nodes>\n";
                os << "  </Edge>\n";
            }

            os << "\n</rdf:RDF>\n";
        }
开发者ID:OpenGraphtheory,项目名称:OpenGraphtheory,代码行数:70,代码来源:rgml.cpp


注:本文中的Graph::BeginEdges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。