1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27#include <easy3d/core/graph.h>
28#include <easy3d/util/initializer.h>
29
37
38
40
41
42
43
44
45#define USE_FOR_LOOP
46
47
48Graph* old_graph_from_previous_example() {
49
50 auto graph =
new Graph;
51
52
57
58
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);
64
65 return graph;
66}
67
68
69int main(int argc, char** argv) {
70
72
73 Graph* graph = old_graph_from_previous_example();
74
75 std::cout << "----------------------------------------\n";
76 std::cout << "The incident vertices of each vertex" << std::endl;
77 std::cout << "----------------------------------------\n";
78
79
81 std::cout << "incident vertices of vertex " << v << ": ";
82#ifdef USE_FOR_LOOP
83
85 std::cout << vv << " ";
86#else
89 do {
91 std::cout << vv << " ";
92 ++cir;
93 } while (cir != end);
94#endif
95 std::cout << std::endl;
96 }
97
98 std::cout << "\n--------------------------------------\n";
99 std::cout << "The incident edges of each vertex" << std::endl;
100 std::cout << "----------------------------------------\n";
101
102
104 std::cout << "incident edges of vertex " << v << ": ";
105#ifdef USE_FOR_LOOP
106
107 for (
auto h : graph->
edges(v))
108 std::cout << h << " ";
109#else
112 do {
114 std::cout << h << " ";
115 ++cir;
116 } while (cir != end);
117#endif
118 std::cout << std::endl;
119 }
120
121 std::cout << "\n--------------------------------------\n";
122 std::cout << "The two end points of each edge" << std::endl;
123 std::cout << "----------------------------------------\n";
124
125
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;
132 }
133
134
135 delete graph;
136
137 return EXIT_SUCCESS;
138}
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
Vec< 3, float > vec3
A 3D point/vector of float type.
Definition types.h:44
void initialize(bool info_to_stdout, bool use_log_file, bool use_setting_file, const std::string &resource_dir)
Initialization of Easy3D.
Definition initializer.cpp:39
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