|
Easy3D 3.0.0
|
Building a Graph from vertices and edges — the 1D connectivity counterpart of a mesh.
Overview
This console tutorial creates the simplest Graph: four vertices positioned in 3D and five edges joining them, then prints the vertex and edge counts. It is the starting point for the graph series (109 connectivity, 110 properties, 111 I/O), just as Tutorial_104 was for surface meshes.
The technique
A Graph stores only vertices and edges — there are no faces and no halfedges. It models pure 1D connectivity: networks, curves, skeletons, road maps, or the edge graph extracted from a mesh. Each vertex still carries a 3D position (the built-in "v:point" property) so the graph can be laid out and drawn in space, and each edge simply records the pair of vertices it joins. Internally the structure keeps per-vertex adjacency so incident edges/neighbors can be queried efficiently (Tutorial_109). Compare the three core structures: PointCloud has points only, Graph adds 1D edges, SurfaceMesh adds 2D faces (halfedges), and PolyMesh adds 3D cells (halffaces). The five edges here form a 4-cycle (v0-v1-v2-v3-v0) plus one diagonal (v1-v3).
Easy3D API
Running it
Console-only. It prints "vertices: 4" and "edges: 5". The graph is heap-allocated with new and explicitly deleted at the end to release its memory.