This example shows how to
- access the incident vertices of each vertex
- access the incident edges of each vertex
- access the two end points of each edge
27#include <easy3d/core/graph.h>
28#include <easy3d/util/initializer.h>
48Graph* old_graph_from_previous_example() {
50 auto graph =
new Graph;
59 graph->add_edge(v0, v1);
60 graph->add_edge(v1, v2);
61 graph->add_edge(v2, v3);
62 graph->add_edge(v3, v0);
63 graph->add_edge(v1, v3);
69int main(
int argc,
char** argv) {
73 Graph* graph = old_graph_from_previous_example();
75 std::cout <<
"----------------------------------------\n";
76 std::cout <<
"The incident vertices of each vertex" << std::endl;
77 std::cout <<
"----------------------------------------\n";
80 for (
auto v : graph->vertices()) {
81 std::cout <<
"incident vertices of vertex " << v <<
": ";
84 for (
auto vv : graph->vertices(v))
85 std::cout << vv <<
" ";
91 std::cout << vv <<
" ";
95 std::cout << std::endl;
98 std::cout <<
"\n--------------------------------------\n";
99 std::cout <<
"The incident edges of each vertex" << std::endl;
100 std::cout <<
"----------------------------------------\n";
103 for (
auto v : graph->vertices()) {
104 std::cout <<
"incident edges of vertex " << v <<
": ";
107 for (
auto h : graph->edges(v))
108 std::cout << h <<
" ";
114 std::cout << h <<
" ";
116 }
while (cir != end);
118 std::cout << std::endl;
121 std::cout <<
"\n--------------------------------------\n";
122 std::cout <<
"The two end points of each edge" << std::endl;
123 std::cout <<
"----------------------------------------\n";
126 for (
auto e : graph->edges()) {
127 std::cout <<
"the two end points of edge " << e <<
": ";
129 std::cout << vs <<
" ";
131 std::cout << vt <<
" " << std::endl;
This class circulates through all edges connected with a vertex. It also acts as a container-concept ...
Definition graph.h:499
This class circulates through all one-ring neighbors of a vertex. It also acts as a container-concept...
Definition graph.h:601
A Graph data structure with easy property management.
Definition graph.h:50
EdgeContainer edges() const
Returns the edge container for range-based for-loops.
Definition graph.h:1153
VertexContainer vertices() const
Returns the vertex container for range-based for-loops.
Definition graph.h:1126
Vertex vertex(Edge e, unsigned int i) const
Returns the i-th vertex of an edge.
Definition graph.h:874
Definition collider.cpp:182
This type represents an edge (internally it is basically an index).
Definition graph.h:151
This type represents a vertex (internally it is basically an index).
Definition graph.h:132