Glauber Dynamics in C
Simulation for Glauber Dynamics written in C11
|
Define the vertex struct and functions relating to it. More...
#include "edge.h"
Go to the source code of this file.
Data Structures | |
struct | vertex |
The vertex struct containing the neighbouring edges as pointers. More... | |
Typedefs | |
typedef struct vertex | vertex |
The typedef of the vertex struct. | |
Functions | |
vertex * | vertex_new () |
Allocate the memory for a new vertex with no neighbours. More... | |
void | vertex_free (vertex *v) |
Free the input vertex pointer and all edges pointing to it. More... | |
void | vertex_add_edge_to_neighbourhood (vertex *v, edge *e) |
Add the edge e to the neighbourhood v->edges. More... | |
void | vertex_rm_edge_from_neighbourhood (vertex *v, edge *e) |
Remove edge e from neighbourhood of vertex v. More... | |
edge * | vertex_find_connecting_edge (vertex *v, int dst) |
Find the edge that connects vertex v with the vertex of index dst. More... | |
Define the vertex struct and functions relating to it.
The vertex struct is defined with its general memory management functions and edge adding and removing utitilities are defined.
Add the edge e to the neighbourhood v->edges.
This also increments vertex::dim and vertex::local_weight accordingly.
void vertex_free | ( | vertex * | v | ) |
Free the input vertex pointer and all edges pointing to it.
The edges are freed in this function since they would otherwise be invalid. Invoke this function only after removing the edge from all other neighbourhoods so that those will not contain an invalid neighbour (cf. graph_rm_edge).
v | The vertex to be freed. |
vertex * vertex_new | ( | ) |
Allocate the memory for a new vertex with no neighbours.
Remove edge e from neighbourhood of vertex v.
The function checks if e is contained in the neighbourhood of v and does nothing if that is not the case. This also decrements vertex::dim and vertex::local_weight accordingly.