]> wirehaze git hosting - graph-theory.git/blobdiff - graph/adj.h

wirehaze git hosting

refac
[graph-theory.git] / graph / adj.h
index b0ec7233c41fc2b70825cbf7d4db014094405fce..2ec54a3b562a450cb4fb316edf2fa3bc20b3fa9c 100644 (file)
@@ -3,31 +3,38 @@
 
 /* adjacency list implementation */
 
 
 /* adjacency list implementation */
 
-struct vertex;
 struct edge;
 struct edge;
-struct graph;
 
 
-struct edge
+struct vertex
 {
 {
-  struct vertex *to;
-  struct edge *next;
+  struct edge *adj; /* edges linked list */
 };
 
 };
 
-struct vertex
+struct edge /* probably not a good name for this */
 {
 {
-  struct edge *adj;
+  struct vertex *to; /* other vertex in edge */
+  struct edge *next;
 };
 
 struct graph
 {
 };
 
 struct graph
 {
-  struct vertex *v;
-  unsigned int nv;
+  struct vertex *v; /* array of vertices */
+  unsigned int nv; /* number of vertices */
 };
 
 struct graph *new_graph (unsigned int nv);
 };
 
 struct graph *new_graph (unsigned int nv);
+void free_graph (struct graph *g);
+
+int add_arc (struct graph *g, unsigned int vi, unsigned int vj);
+void del_arc (struct graph *g, unsigned int vi, unsigned int vj);
 
 
-int new_arc (struct graph *g, unsigned int vi, unsigned int vj);
+int add_edge (struct graph *g, unsigned int vi, unsigned int vj);
+void del_edge (struct graph *g, unsigned int vi, unsigned int vj);
 
 
-int new_edge (struct graph *g, unsigned int vi, unsigned int vj);
+static __inline__ unsigned int
+vertex_id (struct graph *g, struct vertex *v)
+{
+  return (unsigned int)(v - g->v);
+}
 
 #endif /* GRAPH_H  */
 
 #endif /* GRAPH_H  */