OpenMPI
0.1.1
|
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... | |
This file is an implementation of the carto graph base on the graph class.
This file is common to all the carto components.
|
static |
Allocate memory for node.
this function will be assign to the alloc_vertex_data function pointer.
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.
graph | the graph that the nodes belongs to. |
start | the start node |
end | the end node |
weight | the weight of the connection |
References opal_graph_add_edge().
|
static |
A function to copy a node.
this function will be assign in the copy_vertex_data function pointer.
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)
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.
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 |
A function to free node.
this function will be assigned to the free_vertex_data pointer
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.
graph | |
reference_node | |
node_type | the type of the nodes in the returned array |
dist_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.
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.
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.
graph | the graph in which we are searching. |
node_name | the node name. |
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.
graph | an unallocated pointer to a graph. |
graph_type | the type of nodes we want the returned graph will contain. |
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.
graph | the graph that the nodes belongs to. |
node1 | first node. |
node2 | second node. |
References opal_graph_spf().
|
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.
node1 | |
node2 |
Referenced by opal_carto_base_graph_add_node_fn().
|
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.
node | The node we want to print |
Referenced by opal_carto_base_graph_add_node_fn().