Skip to content

Commit a7da93f

Browse files
authored
Merge pull request #6973 from wckzhang/bp_get_vertex
opal/util: Add function to get vertex data from bipartite graph
2 parents 13e4040 + ca70b70 commit a7da93f

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

opal/util/bipartite_graph.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
3-
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
3+
* Copyright (c) 2017-2019 Amazon.com, Inc. or its affiliates. All Rights
44
* reserved.
55
* $COPYRIGHT$
66
*
@@ -411,6 +411,21 @@ int opal_bp_graph_add_vertex(opal_bp_graph_t *g,
411411
return OPAL_SUCCESS;
412412
}
413413

414+
int opal_bp_graph_get_vertex_data(opal_bp_graph_t *g,
415+
int v_index,
416+
void** v_data_out)
417+
{
418+
opal_bp_graph_vertex_t* v;
419+
420+
v = V_ID_TO_PTR(g, v_index);
421+
if (NULL == v) {
422+
return OPAL_ERR_BAD_PARAM;
423+
}
424+
*v_data_out = v->v_data;
425+
426+
return OPAL_SUCCESS;
427+
}
428+
414429
int opal_bp_graph_order(const opal_bp_graph_t *g)
415430
{
416431
return NUM_VERTICES(g);

opal/util/bipartite_graph.h

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
3-
* Copyright (c) 2017 Amazon.com, Inc. or its affiliates. All Rights
3+
* Copyright (c) 2017-2019 Amazon.com, Inc. or its affiliates. All Rights
44
* reserved.
55
* $COPYRIGHT$
66
*
@@ -126,6 +126,20 @@ int opal_bp_graph_add_vertex(opal_bp_graph_t *g,
126126
void *v_data,
127127
int *index_out);
128128

129+
/**
130+
* Get a pointer to the vertex data given the graph and vertex index
131+
* associated with the vertex.
132+
*
133+
* @param[in] g graph the vertex belongs to
134+
* @param[in] v_index integer index of the vertex
135+
* @param[out] v_data_out data associated with the new vertex, may be NULL.
136+
*
137+
* @returns OPAL_SUCCESS or an OMPI error code
138+
*/
139+
int opal_bp_graph_get_vertex_data(opal_bp_graph_t *g,
140+
int v_index,
141+
void** v_data_out);
142+
129143
/**
130144
* compute the order of a graph (number of vertices)
131145
*

0 commit comments

Comments
 (0)