Debian Codegraph @

lib/ortho/rawgraph.h

raw
1 /*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11 #pragma once
12
13 #include <stdbool.h>
14 #include <stddef.h>
15 #include <util/list.h>
16
17 typedef LIST(size_t) adj_list_t;
18
19 typedef struct {
20 int color;
21 int topsort_order;
22 adj_list_t adj_list; ///< adjacency list
23 } vertex;
24
25 typedef struct {
26 size_t nvs;
27 vertex* vertices;
28 } rawgraph;
29
30 /// makes a graph with n vertices, 0 edges
31 rawgraph *make_graph(size_t n);
32
33 extern void free_graph(rawgraph*);
34
35 /// inserts edge FROM v1 to v2
36 void insert_edge(rawgraph *, size_t v1, size_t v2);
37
38 /// removes any edge between v1 to v2 -- irrespective of direction
39 void remove_redge(rawgraph *, size_t v1, size_t v2);
40
41 /// tests if there is an edge FROM v1 TO v2
42 bool edge_exists(rawgraph *, size_t v1, size_t v2);
43
44 /* topologically sorts the directed graph */
45 extern void top_sort(rawgraph*);