Sturk 1.0.2
Publish-subscribe C implementation.
Loading...
Searching...
No Matches
graph.h File Reference

Graph. More...

#include "vx/vertegs.h"
Include dependency graph for graph.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define VX_TYPEOF(var)   __typeof__(var)
 Get the type of a variable.
 
#define VX_GRAPH(name, deg, type)
 Define the graph.
 
#define vx_graph_2vx(graph)    (0 ? (struct Vertegs*)(graph)->vx_graph_nbor : (struct Vertegs*)(graph))
 Cast to generic vertex from a graph node.
 
#define vx_graph_4vx(v, graph)
 Cast from a generic vertex to a graph node.
 
#define vx_graphp_2vxp(graphp)    (0 ? (*(graphp))->vx_graph_nbor : (struct Vertegs**)(graphp))
 Cast to generic vertex double pointer from a graph node double pointer.
 
#define vx_graph_datap(graph)   (&(graph)->vx_graph_data)
 Get a pointer to the data member of a graph node.
 
#define vx_graph_foredge(type, i, graphp, edge)    for (type** i = graphp; *i; i = (type**)&(*i)->vx_graph_nbor[edge])
 Traverse a graph.
 

Detailed Description

Graph.

Macro Definition Documentation

◆ VX_GRAPH

#define VX_GRAPH (   name,
  deg,
  type 
)
Value:
name \
{ \
struct Vertegs* vx_graph_nbor[deg]; \
type vx_graph_data; \
}
The data type for a graph vertex.
Definition vertegs.h:77

Define the graph.

Parameters
[in]nameThe name of the type used for the graph.
[in]degThe degree of vertices - the number of neighbours.
[in]typeThe type of the data held by name.

This macro will define a compound type (must be struct or union) name, a type for a graph entry that holds the data of the type type.

◆ vx_graph_2vx

#define vx_graph_2vx (   graph)     (0 ? (struct Vertegs*)(graph)->vx_graph_nbor : (struct Vertegs*)(graph))

Cast to generic vertex from a graph node.

Parameters
[in]graphThe graph node.
Returns
The vertex.

◆ vx_graph_4vx

#define vx_graph_4vx (   v,
  graph 
)
Value:
(0 ? (VX_TYPEOF(graph))((graph)->vx_graph_nbor[0] = (v)->nbor[0]) \
: ((VX_TYPEOF(graph))(v)))
#define VX_TYPEOF(var)
Get the type of a variable.
Definition graph.h:56

Cast from a generic vertex to a graph node.

Parameters
[in]vThe vertex.
[in]graphA variable of the same type as the graph node.
Returns
The graph node.

◆ vx_graph_datap

#define vx_graph_datap (   graph)    (&(graph)->vx_graph_data)

Get a pointer to the data member of a graph node.

Parameters
[in]graphThe graph node.
Returns
The pointer to the data.

◆ vx_graph_foredge

#define vx_graph_foredge (   type,
  i,
  graphp,
  edge 
)     for (type** i = graphp; *i; i = (type**)&(*i)->vx_graph_nbor[edge])

Traverse a graph.

Traverse the graph of type type referenced by graphp along the edges of of index edge, assigning every node in turn to i.

◆ vx_graphp_2vxp

#define vx_graphp_2vxp (   graphp)     (0 ? (*(graphp))->vx_graph_nbor : (struct Vertegs**)(graphp))

Cast to generic vertex double pointer from a graph node double pointer.

Parameters
[in]graphpThe graph node double pointer.
Returns
The vertex double pointer.

◆ VX_TYPEOF

#define VX_TYPEOF (   var)    __typeof__(var)

Get the type of a variable.

Note
For strict ansi build this always returns a void pointer.