68 std::vector<std::vector<int>>
edges = {};
146 Graph(std::vector<float> x, std::vector<float> y) :
Cloud(x, y){};
161 void add_edge(std::vector<int> edge,
float weight);
174 void add_edge(std::vector<int> edge);
194 std::vector<int>
dijkstra(
int source_point_index,
int target_point_index);
303 bool color_by_edge_weight =
true);
330 int orientation = 0.f,
331 float persistence = 1.f);
359 Array *p_noise_x =
nullptr,
360 Array *p_noise_y =
nullptr,
376 void to_csv(std::string fname_xy, std::string fname_adjacency);
388 void to_png(std::string fname, Vec2<int> shape = {512, 512});
Declaration of the Array class for 2D floating-point arrays with various mathematical operations and ...
unsigned int uint
Definition array.hpp:14
Array class, helper to manipulate 2D float array with "(i, j)" indexing.
Definition array.hpp:32
Represents a collection of unordered points in 2D space.
Definition cloud.hpp:55
std::vector< Point > points
Points of the cloud.
Definition cloud.hpp:57
Graph class, to manipulate graphs in 2D.
Definition graph.hpp:58
std::vector< float > get_edge_y_pairs()
Return y coordinates of the edges (as pairs).
Definition graph.cpp:127
std::vector< int > dijkstra(int source_point_index, int target_point_index)
Return the shortest route between two points using Dijkstra's algorithm.
Definition graph.cpp:21
Graph(std::vector< Point > points)
Construct a new Graph object based on a list of points.
Definition graph.hpp:132
Graph()
Construct a new Graph object.
Definition graph.hpp:108
void add_edge(std::vector< int > edge, float weight)
Add an edge to the graph.
Definition graph.cpp:86
void to_array_fractalize(Array &array, Vec4< float > bbox, int iterations, uint seed, float sigma=0.3f, int orientation=0.f, float persistence=1.f)
Apply fractalization to graph edges and project to an array.
Definition graph.cpp:285
void to_csv(std::string fname_xy, std::string fname_adjacency)
Export graph data to CSV files.
Definition graph.cpp:359
void update_adjacency_matrix()
Update the adjacency matrix of the graph.
Definition graph.cpp:393
Graph(std::vector< float > x, std::vector< float > y)
Construct a new Graph object based on x and y coordinates.
Definition graph.hpp:146
std::vector< float > weights
Edge weights.
Definition graph.hpp:78
void print()
Print the graph data to the standard output.
Definition graph.cpp:194
std::map< std::pair< int, int >, float > adjacency_matrix
Adjacency matrix.
Definition graph.hpp:98
void to_png(std::string fname, Vec2< int > shape={512, 512})
Export the graph as a PNG image file.
Definition graph.cpp:386
float get_edge_length(int k)
Get the length of edge k.
Definition graph.cpp:98
std::vector< float > get_edge_x_pairs()
Return x coordinates of the edges (as pairs).
Definition graph.cpp:115
std::vector< float > get_lengths()
Get the length of all the edges.
Definition graph.cpp:104
std::vector< std::vector< int > > connectivity
Store point connectivity.
Definition graph.hpp:88
size_t get_nedges()
Get the number of edges in the graph.
Definition graph.cpp:139
void to_array(Array &array, Vec4< float > bbox, bool color_by_edge_weight=true)
Project the graph to an array and optionally color by edge weight.
Definition graph.cpp:263
Graph remove_orphan_points()
Remove orphan points from the graph.
Definition graph.cpp:217
void update_connectivity()
Update the point connectivity information.
Definition graph.cpp:407
Graph minimum_spanning_tree_prim()
Generate a Minimum Spanning Tree (MST) of the graph using Prim's algorithm.
Definition graph.cpp:144
std::vector< std::vector< int > > edges
Edges of the graph.
Definition graph.hpp:68
Array to_array_sdf(Vec2< int > shape, Vec4< float > bbox, Array *p_noise_x=nullptr, Array *p_noise_y=nullptr, Vec4< float > bbox_array={0.f, 1.f, 0.f, 1.f})
Generate an array filled with the Signed Distance Function (SDF) to the graph.
Definition graph.cpp:315
Graph(Cloud cloud)
Construct a new Graph object based on a cloud of points.
Definition graph.hpp:120
Definition of the Cloud class for manipulating sets of 2D points.
Definition algebra.hpp:28
Defines a class for representing and manipulating 3D points.
Vec2 class for basic manipulation of 2D vectors.
Definition algebra.hpp:40
Vec4 class for basic manipulation of 4D vectors.
Definition algebra.hpp:564