diff options
| author | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-04-06 17:58:00 -0400 |
|---|---|---|
| committer | Quentin Young <qlyoung@cumulusnetworks.com> | 2018-04-06 17:59:39 -0400 |
| commit | 9428e08906c415d538dc22104a70889f3152a074 (patch) | |
| tree | e45224077e2002052fc4ab3d1262e7d49c2e9356 /lib/graph.h | |
| parent | 52483fa6ff0957032f73c6b6c4aa3402476a5b90 (diff) | |
lib: add graph_find_node
Allows finding a graph node by its data pointer.
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'lib/graph.h')
| -rw-r--r-- | lib/graph.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/graph.h b/lib/graph.h index 10ee00feda..d6dfef5a63 100644 --- a/lib/graph.h +++ b/lib/graph.h @@ -24,6 +24,7 @@ #ifndef _ZEBRA_COMMAND_GRAPH_H #define _ZEBRA_COMMAND_GRAPH_H +#include <stdbool.h> #include "vector.h" struct graph { @@ -91,4 +92,23 @@ void graph_remove_edge(struct graph_node *from, struct graph_node *to); */ void graph_delete_graph(struct graph *graph); +/* + * Finds a node in the graph. + * + * @param[in] graph the graph to search in + * @param[in] data the data to key off + * @return the first graph node whose data pointer matches `data` + */ +struct graph_node *graph_find_node(struct graph *graph, void *data); + + +/* + * Determines whether two nodes have a directed edge between them. + * + * @param from + * @param to + * @return whether there is a directed edge from `from` to `to`. + */ +bool graph_has_edge(struct graph_node *from, struct graph_node *to); + #endif /* _ZEBRA_COMMAND_GRAPH_H */ |
