OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Functions
carto_base_graph.c File Reference

This file is an implementation of the carto graph base on the graph class. More...

`#include "opal_config.h"`
`#include "opal/class/opal_graph.h"`
`#include "opal/mca/carto/carto.h"`
`#include "opal/mca/carto/base/carto_base_graph.h"`

## Functions
static void | opal_carto_base_free_node (void *node)
| A function to free node. More...
static void | opal_carto_base_copy_nodes (void **dst, void *src)
| A function to copy a node. More...
static void * | opal_carto_base_alloc_node (void)
| Allocate memory for node. More...
static int | opal_carto_compare_nodes (void *node1, void *node2)
| Compare two nodes. More...
static char * | opal_carto_print_node (void *node)
| A function to print a node. More...
void | opal_carto_base_graph_create_fn (opal_carto_graph_t **graph)
| Create new carto graph. More...
void | opal_carto_base_graph_add_node_fn (opal_carto_graph_t *graph, opal_carto_base_node_t *node)
| Add a node to carto graph. More...
void | opal_carto_base_free_graph_fn (opal_carto_graph_t *graph)
| Free a carto graph. More...
int | opal_carto_base_connect_nodes_fn (opal_carto_graph_t *graph, opal_carto_base_node_t *start, opal_carto_base_node_t *end, uint32_t weight)
| Connect two nodes by adding an edge to the graph. More...
void | opal_carto_base_duplicate_graph_fn (opal_carto_graph_t **destination, const opal_carto_graph_t *source, const char *node_type)
| Duplicate a carto graph and reduce the new graph to contain nodes from a ceratin type(s) More...
int | opal_carto_base_get_nodes_distance_fn (opal_carto_graph_t *graph, opal_carto_base_node_t *reference_node, const char *node_type, opal_value_array_t *dist_array)
| opal_carto_base_get_nodes_distance - returns the distance of all the nodes from the reference node. More...
uint32_t | opal_carto_base_graph_spf_fn (opal_carto_graph_t *graph, opal_carto_base_node_t *node1, opal_carto_base_node_t *node2)
| Find the shortest path between two nodes in the graph. More...
opal_carto_base_node_t * | opal_carto_base_graph_find_node_fn (opal_carto_graph_t *graph, const char *node_name)
| Find a node in the graph according to its name. More...
int | opal_carto_base_graph_get_host_graph_fn (opal_carto_graph_t **graph, const char *graph_type)
| Get the host cartography graph. More...

## Detailed Description

This file is an implementation of the carto graph base on the graph class.

This file is common to all the carto components.

## Function Documentation

static void * opal_carto_base_alloc_node | ( | void |  | ) |
| static

Allocate memory for node.

this function will be assign to the alloc_vertex_data function pointer.

Returns
  void*

Referenced by opal_carto_base_graph_add_node_fn().

int opal_carto_base_connect_nodes_fn | ( | opal_carto_graph_t * | graph,
|  | opal_carto_base_node_t * | start,
|  | opal_carto_base_node_t * | end,
|  | uint32_t | weight
| ) |  |

Connect two nodes by adding an edge to the graph.

Parameters

  graph | the graph that the nodes belongs to.
  start | the start node
  end | the end node
  weight | the weight of the connection

Returns
  int success or error (if one of the nodes does not belong to the graph.

References opal_graph_add_edge().

static void opal_carto_base_copy_nodes | ( | void ** | dst,
|  | void * | src
| ) |  |
| static

A function to copy a node.

this function will be assign in the copy_vertex_data function pointer.

Parameters

  dst | the destination node.
  src | the source node.

Referenced by opal_carto_base_graph_add_node_fn().

void opal_carto_base_duplicate_graph_fn | ( | opal_carto_graph_t ** | destination,
|  | const opal_carto_graph_t * | source,
|  | const char * | node_type
| ) |  |

Duplicate a carto graph and reduce the new graph to contain nodes from a ceratin type(s)

Parameters

  destination | The new graph.
  source | the original graph.
  node_type | the node type(s) that the new graph will include.

References OBJ_RELEASE, opal_graph_duplicate(), opal_graph_get_graph_vertices(), opal_graph_remove_vertex(), opal_pointer_array_get_item(), and opal_pointer_array_init().

Referenced by opal_carto_base_graph_get_host_graph_fn().

void opal_carto_base_free_graph_fn | ( | opal_carto_graph_t * | graph | ) |

Free a carto graph.

Parameters

  graph | the graph we want to free.

References OBJ_RELEASE, opal_carto_base_free_node(), opal_graph_get_graph_vertices(), opal_pointer_array_get_item(), and opal_pointer_array_init().

static void opal_carto_base_free_node | ( | void * | node | ) |
| static

A function to free node.

this function will be assigned to the free_vertex_data pointer

Parameters

  node | the node to free.

Referenced by opal_carto_base_free_graph_fn(), and opal_carto_base_graph_add_node_fn().

int opal_carto_base_get_nodes_distance_fn | ( | opal_carto_graph_t * | graph,
|  | opal_carto_base_node_t * | reference_node,
|  | const char * | node_type,
|  | opal_value_array_t * | dist_array
| ) |  |

opal_carto_base_get_nodes_distance - returns the distance of all the nodes from the reference node.

Parameters

  graph |
  reference_node |
  node_type | the type of the nodes in the returned array
  dist_array |

Returns
  int number of nodes in the returned array.

References opal_graph_dijkstra().

void opal_carto_base_graph_add_node_fn | ( | opal_carto_graph_t * | graph,
|  | opal_carto_base_node_t * | node
| ) |  |

Add a node to carto graph.

Parameters

  graph | the carto graph to add the node to.
  node | the node to add.

References opal_carto_base_alloc_node(), opal_carto_base_copy_nodes(), opal_carto_base_free_node(), opal_carto_compare_nodes(), opal_carto_print_node(), and opal_graph_add_vertex().

void opal_carto_base_graph_create_fn | ( | opal_carto_graph_t ** | graph | ) |

Create new carto graph.

Parameters

  graph | an empty graph pointer

opal_carto_base_node_t* opal_carto_base_graph_find_node_fn | ( | opal_carto_graph_t * | graph,
|  | const char * | node_name
| ) |  |

Find a node in the graph according to its name.

Parameters

  graph | the graph in which we are searching.
  node_name | the node name.

Returns
  opal_carto_base_node_t* the node with the name -if found or NULL.

find a vertex in the graph. the find_vertex uses the compare_vertex_data method. in our case, compare_vertex_data is assigned to opal_carto_compare_nodes that compares two nodes names.

References opal_graph_find_vertex().

int opal_carto_base_graph_get_host_graph_fn | ( | opal_carto_graph_t ** | graph,
|  | const char * | graph_type
| ) |  |

Get the host cartography graph.

Parameters

  graph | an unallocated pointer to a graph.
  graph_type | the type of nodes we want the returned graph will contain.

Returns
  int success or error

References opal_carto_base_duplicate_graph_fn().

uint32_t opal_carto_base_graph_spf_fn | ( | opal_carto_graph_t * | graph,
|  | opal_carto_base_node_t * | node1,
|  | opal_carto_base_node_t * | node2
| ) |  |

Find the shortest path between two nodes in the graph.

Parameters

  graph | the graph that the nodes belongs to.
  node1 | first node.
  node2 | second node.

Returns
  uint32_t he distance between the nodes.

References opal_graph_spf().

static int opal_carto_compare_nodes | ( | void * | node1,
|  | void * | node2
| ) |  |
| static

Compare two nodes.

in our case we needs to compare only the node name. this function will be assign to the compare vertex data function pointer.

Parameters

  node1 |
  node2 |

Returns
  int 0-equal, 1-the first is bigger, -1-the first is smaller.

Referenced by opal_carto_base_graph_add_node_fn().

static char * opal_carto_print_node | ( | void * | node | ) |
| static

A function to print a node.

this function allocates buffer and prints in it the node type and the node name. this function will be assign to the print_vertex function pointer when building a new node.

Parameters

  node | The node we want to print

Returns
  char* the string to print.

Referenced by opal_carto_base_graph_add_node_fn().