This example shows how to construct a graph from its vertices and edges
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
34
35
37
38
39int main(int argc, char** argv) {
40
42
43
44 auto graph =
new Graph;
45
46
51
52
53 graph->add_edge(v0, v1);
54 graph->add_edge(v1, v2);
55 graph->add_edge(v2, v3);
56 graph->add_edge(v3, v0);
57 graph->add_edge(v1, v3);
58
59 std::cout << "vertices: " << graph->n_vertices() << std::endl;
60 std::cout << "edges: " << graph->n_edges() << std::endl;
61
62
63 delete graph;
64
65 return EXIT_SUCCESS;
66}
A Graph data structure with easy property management.
Definition graph.h:50
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 a vertex (internally it is basically an index).
Definition graph.h:132