65 |
65 |
66 |
66 |
67 ///Adds a Petersen graph to \c G. |
67 ///Adds a Petersen graph to \c G. |
68 |
68 |
69 ///Adds a Petersen graph to \c G. |
69 ///Adds a Petersen graph to \c G. |
70 ///\return The nodes end edges og the generated graph. |
70 ///\return The nodes and edges of the generated graph. |
71 |
71 |
72 template<typename Graph> |
72 template<typename Graph> |
73 PetStruct<Graph> addPetersen(Graph &G,int num=5) |
73 PetStruct<Graph> addPetersen(Graph &G,int num=5) |
74 { |
74 { |
75 PetStruct<Graph> n; |
75 PetStruct<Graph> n; |
85 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5])); |
85 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5])); |
86 } |
86 } |
87 return n; |
87 return n; |
88 } |
88 } |
89 |
89 |
|
90 ///Structure returned by \ref addSymPetersen(). |
90 |
91 |
|
92 ///Structure returned by \ref addSymPetersen(). |
|
93 /// |
|
94 template<class Graph> struct SymPetStruct |
|
95 { |
|
96 ///Vector containing the outer nodes. |
|
97 std::vector<typename Graph::Node> outer; |
|
98 ///Vector containing the inner nodes. |
|
99 std::vector<typename Graph::Node> inner; |
|
100 ///Vector containing the edges of the inner circle. |
|
101 std::vector<typename Graph::SymEdge> incir; |
|
102 ///Vector containing the edges of the outer circle. |
|
103 std::vector<typename Graph::SymEdge> outcir; |
|
104 ///Vector containing the chord edges. |
|
105 std::vector<typename Graph::SymEdge> chords; |
|
106 }; |
|
107 |
|
108 ///Adds a Petersen graph to the symmetric \c G. |
|
109 |
|
110 ///Adds a Petersen graph to the symmetric \c G. |
|
111 ///\return The nodes and edges of the generated graph. |
|
112 |
|
113 template<typename Graph> |
|
114 SymPetStruct<Graph> addSymPetersen(Graph &G,int num=5) |
|
115 { |
|
116 SymPetStruct<Graph> n; |
|
117 |
|
118 for(int i=0;i<num;i++) { |
|
119 n.outer.push_back(G.addNode()); |
|
120 n.inner.push_back(G.addNode()); |
|
121 } |
|
122 |
|
123 for(int i=0;i<num;i++) { |
|
124 n.chords.push_back(G.addEdge(n.outer[i],n.inner[i])); |
|
125 n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%5])); |
|
126 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%5])); |
|
127 } |
|
128 return n; |
|
129 } |
91 |
130 |
92 #endif |
131 #endif |