CMR  1.3.0
Classes | Typedefs | Functions
Graph

Classes

struct  CMR_GRAPH_NODE_DATA
 
struct  CMR_GRAPH_ARC_DATA
 
struct  CMR_GRAPH
 

Typedefs

typedef int CMR_GRAPH_NODE
 Reference to a node of CMR_GRAPH. More...
 
typedef int CMR_GRAPH_EDGE
 Reference to an edge of CMR_GRAPH. More...
 
typedef int CMR_GRAPH_ITER
 Reference to an edge iterator of CMR_GRAPH. More...
 

Functions

static size_t CMRgraphMemNodes (CMR_GRAPH *graph)
 Returns number of nodes for which memory is allocated. More...
 
static size_t CMRgraphNumNodes (CMR_GRAPH *graph)
 Returns number of nodes. More...
 
static size_t CMRgraphMemEdges (CMR_GRAPH *graph)
 Returns number of edges for which memory is allocated. More...
 
static size_t CMRgraphNumEdges (CMR_GRAPH *graph)
 Returns number of edges. More...
 
static CMR_GRAPH_NODE CMRgraphEdgeU (CMR_GRAPH *graph, CMR_GRAPH_EDGE e)
 Returns node u of edge e. More...
 
static CMR_GRAPH_NODE CMRgraphEdgeV (CMR_GRAPH *graph, CMR_GRAPH_EDGE e)
 Returns node v of edge e. More...
 
CMR_EXPORT CMR_ERROR CMRgraphCreateEmpty (CMR *cmr, CMR_GRAPH **pgraph, int memNodes, int memEdges)
 Creates an empty graph. More...
 
CMR_EXPORT CMR_ERROR CMRgraphFree (CMR *cmr, CMR_GRAPH **pgraph)
 Frees a graph. More...
 
CMR_EXPORT CMR_ERROR CMRgraphClear (CMR *cmr, CMR_GRAPH *graph)
 Removes all nodes and columns, keeping the memory. More...
 
CMR_EXPORT CMR_ERROR CMRgraphAddNode (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_NODE *pnode)
 Adds a node to a graph. More...
 
CMR_EXPORT CMR_ERROR CMRgraphAddEdge (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_NODE u, CMR_GRAPH_NODE v, CMR_GRAPH_EDGE *pedge)
 Adds an edge to a graph. More...
 
CMR_EXPORT CMR_ERROR CMRgraphDeleteNode (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_NODE v)
 Removes node v and all its incident edges from graph. More...
 
CMR_EXPORT CMR_ERROR CMRgraphDeleteEdge (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_EDGE e)
 Removes edge e from graph. More...
 
static CMR_GRAPH_NODE CMRgraphNodesFirst (CMR_GRAPH *graph)
 Returns a node iterator for iterating over all nodes. More...
 
static bool CMRgraphNodesValid (CMR_GRAPH *graph, CMR_GRAPH_NODE v)
 Return true if and only if this v is not the last node in node iteration. More...
 
static CMR_GRAPH_NODE CMRgraphNodesNext (CMR_GRAPH *graph, CMR_GRAPH_NODE v)
 Returns the next node after v. More...
 
static CMR_GRAPH_ITER CMRgraphIncFirst (CMR_GRAPH *graph, CMR_GRAPH_NODE v)
 Returns an iterator for all edges incident to node v. More...
 
static bool CMRgraphIncValid (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns true if iterator i for all incident edges of some node is valid. More...
 
static CMR_GRAPH_ITER CMRgraphIncNext (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns the iterator following iterator i for all edges incident to some node. More...
 
static CMR_GRAPH_EDGE CMRgraphIncEdge (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Converts an iterator for edges incident to a node to the actual edge. More...
 
static CMR_GRAPH_NODE CMRgraphIncSource (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns the node of which iterator i traverses through incident edges. More...
 
static CMR_GRAPH_NODE CMRgraphIncTarget (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns the end node of the edge corresponding to this iterator i. More...
 
static CMR_GRAPH_ITER CMRgraphEdgesNext (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns iterator of next edge in list of all edges. More...
 
static CMR_GRAPH_ITER CMRgraphEdgesFirst (CMR_GRAPH *graph)
 Returns iterator for all edges of graph. More...
 
static bool CMRgraphEdgesValid (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns true if and only if iterator i for all edges is valid. More...
 
static CMR_GRAPH_EDGE CMRgraphEdgesEdge (CMR_GRAPH *graph, CMR_GRAPH_ITER i)
 Returns the actual edge, iterator i represents. More...
 
CMR_EXPORT CMR_ERROR CMRgraphPrint (CMR_GRAPH *graph, FILE *stream)
 Prints the graph, writing to stream. More...
 
CMR_EXPORT CMR_ERROR CMRgraphMergeNodes (CMR *cmr, CMR_GRAPH *graph, CMR_GRAPH_NODE u, CMR_GRAPH_NODE v)
 Merges two nodes u and v of graph. More...
 
CMR_EXPORT CMR_ERROR CMRgraphCreateFromEdgeList (CMR *cmr, CMR_GRAPH **pgraph, CMR_ELEMENT **pedgeElements, char ***pnodeLabels, FILE *stream)
 

Detailed Description

Undirected graphs.

Typedef Documentation

◆ CMR_GRAPH_EDGE

typedef int CMR_GRAPH_EDGE

Reference to an edge of CMR_GRAPH.

◆ CMR_GRAPH_ITER

typedef int CMR_GRAPH_ITER

Reference to an edge iterator of CMR_GRAPH.

◆ CMR_GRAPH_NODE

typedef int CMR_GRAPH_NODE

Reference to a node of CMR_GRAPH.

Function Documentation

◆ CMRgraphAddEdge()

CMR_EXPORT CMR_ERROR CMRgraphAddEdge ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_NODE  u,
CMR_GRAPH_NODE  v,
CMR_GRAPH_EDGE pedge 
)

Adds an edge to a graph.

Adds an edge to a graph.

Returns
Edge of new edge.
Parameters
cmrCMR environment.
graphGraph.
uOne node of the edge.
vOther node of the edge.
pedgePointer for storinge the new edge, or NULL.

◆ CMRgraphAddNode()

CMR_EXPORT CMR_ERROR CMRgraphAddNode ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_NODE pnode 
)

Adds a node to a graph.

Adds a node to a graph.

Returns
Node structure of new node.
Parameters
cmrCMR environment.
graphGraph.
pnodePointer for storing the new node, or NULL.

◆ CMRgraphClear()

CMR_EXPORT CMR_ERROR CMRgraphClear ( CMR cmr,
CMR_GRAPH graph 
)

Removes all nodes and columns, keeping the memory.

Parameters
cmrCMR environment.
graphGraph structure.

◆ CMRgraphCreateEmpty()

CMR_EXPORT CMR_ERROR CMRgraphCreateEmpty ( CMR cmr,
CMR_GRAPH **  pgraph,
int  memNodes,
int  memEdges 
)

Creates an empty graph.

Parameters
cmrCMR environment.
pgraphPointer for storing the graph.
memNodesAllocate memory for this number of nodes.
memEdgesAllocate memory for this number of edges.

◆ CMRgraphCreateFromEdgeList()

CMR_EXPORT CMR_ERROR CMRgraphCreateFromEdgeList ( CMR cmr,
CMR_GRAPH **  pgraph,
CMR_ELEMENT **  pedgeElements,
char ***  pnodeLabels,
FILE *  stream 
)
Parameters
cmrCMR environment.
pgraphPointer for storing the graph.
pedgeElementsPointer for storing element of each edge (may be NULL).
pnodeLabelsPointer for storing string node labels (may be NULL).
streamFile stream to read from.

◆ CMRgraphDeleteEdge()

CMR_EXPORT CMR_ERROR CMRgraphDeleteEdge ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_EDGE  e 
)

Removes edge e from graph.

Parameters
cmrCMR environment.
graphGraph.
eEdge to be deleted.

◆ CMRgraphDeleteNode()

CMR_EXPORT CMR_ERROR CMRgraphDeleteNode ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_NODE  v 
)

Removes node v and all its incident edges from graph.

Parameters
cmrCMR environment.
graphGraph.
vNode to be deleted.

◆ CMRgraphEdgesEdge()

static CMR_GRAPH_EDGE CMRgraphEdgesEdge ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns the actual edge, iterator i represents.

Parameters
graphGraph structure.
iIterator for edges.

◆ CMRgraphEdgesFirst()

static CMR_GRAPH_ITER CMRgraphEdgesFirst ( CMR_GRAPH graph)
inlinestatic

Returns iterator for all edges of graph.

Parameters
graphGraph.

◆ CMRgraphEdgesNext()

static CMR_GRAPH_ITER CMRgraphEdgesNext ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns iterator of next edge in list of all edges.

Parameters
graphGraph.
iCurrent edge iterator.

◆ CMRgraphEdgesValid()

static bool CMRgraphEdgesValid ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns true if and only if iterator i for all edges is valid.

Parameters
graphGraph structure.
iIterator for edges incident to a node.

◆ CMRgraphEdgeU()

static CMR_GRAPH_NODE CMRgraphEdgeU ( CMR_GRAPH graph,
CMR_GRAPH_EDGE  e 
)
inlinestatic

Returns node u of edge e.

Parameters
graphGraph.
eEdge of graph.

◆ CMRgraphEdgeV()

static CMR_GRAPH_NODE CMRgraphEdgeV ( CMR_GRAPH graph,
CMR_GRAPH_EDGE  e 
)
inlinestatic

Returns node v of edge e.

Parameters
graphGraph.
eEdge of graph.

◆ CMRgraphFree()

CMR_EXPORT CMR_ERROR CMRgraphFree ( CMR cmr,
CMR_GRAPH **  pgraph 
)

Frees a graph.

Parameters
cmrCMR environment.
pgraphPointer to graph.

◆ CMRgraphIncEdge()

static CMR_GRAPH_EDGE CMRgraphIncEdge ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Converts an iterator for edges incident to a node to the actual edge.

Parameters
graphGraph.
iIterator for edges incident to a node.

◆ CMRgraphIncFirst()

static CMR_GRAPH_ITER CMRgraphIncFirst ( CMR_GRAPH graph,
CMR_GRAPH_NODE  v 
)
inlinestatic

Returns an iterator for all edges incident to node v.

Parameters
graphGraph.
vNode.

◆ CMRgraphIncNext()

static CMR_GRAPH_ITER CMRgraphIncNext ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns the iterator following iterator i for all edges incident to some node.

Parameters
graphGraph.
iIterator for edges incident to a node.

◆ CMRgraphIncSource()

static CMR_GRAPH_NODE CMRgraphIncSource ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns the node of which iterator i traverses through incident edges.

Parameters
graphGraph structure.
iIterator for edges incident to a node.

◆ CMRgraphIncTarget()

static CMR_GRAPH_NODE CMRgraphIncTarget ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns the end node of the edge corresponding to this iterator i.

Parameters
graphGraph structure.
iIterator for edges incident to a node.

◆ CMRgraphIncValid()

static bool CMRgraphIncValid ( CMR_GRAPH graph,
CMR_GRAPH_ITER  i 
)
inlinestatic

Returns true if iterator i for all incident edges of some node is valid.

Parameters
graphGraph structure.
iIterator for edges incident to a node.

◆ CMRgraphMemEdges()

static size_t CMRgraphMemEdges ( CMR_GRAPH graph)
inlinestatic

Returns number of edges for which memory is allocated.

Parameters
graphGraph.

◆ CMRgraphMemNodes()

static size_t CMRgraphMemNodes ( CMR_GRAPH graph)
inlinestatic

Returns number of nodes for which memory is allocated.

Parameters
graphGraph.

◆ CMRgraphMergeNodes()

CMR_EXPORT CMR_ERROR CMRgraphMergeNodes ( CMR cmr,
CMR_GRAPH graph,
CMR_GRAPH_NODE  u,
CMR_GRAPH_NODE  v 
)

Merges two nodes u and v of graph.

Parameters
cmrCMR environment.
graphGraph.
uFirst node.
vSecond node.

◆ CMRgraphNodesFirst()

static CMR_GRAPH_NODE CMRgraphNodesFirst ( CMR_GRAPH graph)
inlinestatic

Returns a node iterator for iterating over all nodes.

Parameters
graphGraph.

◆ CMRgraphNodesNext()

static CMR_GRAPH_NODE CMRgraphNodesNext ( CMR_GRAPH graph,
CMR_GRAPH_NODE  v 
)
inlinestatic

Returns the next node after v.

Parameters
graphGraph.
vNode.

◆ CMRgraphNodesValid()

static bool CMRgraphNodesValid ( CMR_GRAPH graph,
CMR_GRAPH_NODE  v 
)
inlinestatic

Return true if and only if this v is not the last node in node iteration.

Parameters
graphGraph.
vNode.

◆ CMRgraphNumEdges()

static size_t CMRgraphNumEdges ( CMR_GRAPH graph)
inlinestatic

Returns number of edges.

Parameters
graphGraph.

◆ CMRgraphNumNodes()

static size_t CMRgraphNumNodes ( CMR_GRAPH graph)
inlinestatic

Returns number of nodes.

Parameters
graphGraph.

◆ CMRgraphPrint()

CMR_EXPORT CMR_ERROR CMRgraphPrint ( CMR_GRAPH graph,
FILE *  stream 
)

Prints the graph, writing to stream.

Parameters
graphGraph structure.
streamStream.