Index: libabac/abac_graph.c
===================================================================
--- libabac/abac_graph.c	(revision ebe824c83add4831fddaeae8b0101869d9d83fe4)
+++ libabac/abac_graph.c	(revision 9a411d7accba6ff50666bab7e0bb3c3ac7a85172)
@@ -47,12 +47,5 @@
 
 // ugghhhghhhghh need this for intersections
-abac_list_t *abac_credential_prereqs(abac_credential_t *);
-
-/**
- * True iff a vertex is linking.
- */
-static inline int _vertex_is_intersection(abac_vertex_t *vertex) {
-    return vertex->role == NULL;
-}
+abac_list_t *abac_role_prereqs(abac_role_t *);
 
 /**
@@ -109,5 +102,18 @@
 
         // for intersections, always NULL on normal vertices
-        vertex->prereqs = NULL;
+        if (abac_role_is_intersection(role)) {
+            abac_role_t *prereq;
+            vertex->prereqs = abac_list_new();
+
+            // add each prereq to the vertex
+            abac_list_foreach(abac_role_prereqs(role), prereq,
+                abac_vertex_t *tail_vertex = _get_vertex(graph, prereq);
+                abac_list_add(vertex->prereqs, tail_vertex);
+            );
+        }
+
+        // normal edges have no prereqs
+        else
+            vertex->prereqs = NULL;
 
         // add it to the vertices
@@ -116,73 +122,4 @@
 
     return vertex;
-}
-
-/**
- * convert a list of prereqs to a string suitable for use as a hash key
- * format: role & role & ... & role
- */
-static char *_prereq_key(abac_list_t *prereqs) {
-    abac_role_t *role;
-    char *string;
-    int i = 0, size;
-    size_t len = 0;
-
-    // find the required size
-    abac_list_foreach(prereqs, role,
-        len += strlen(abac_role_string(role)) + 3;
-    );
-
-    string = abac_xmalloc(len);
-    string[0] = '\0';
-
-    size = abac_list_size(prereqs);
-
-    // concat the names
-    abac_list_foreach(prereqs, role,
-        strcat(string, abac_role_string(role));
-        if (i++ < size - 1)
-            strcat(string, " & ");
-    );
-
-    return string;
-}
-
-/**
- * Find/create intersection vertex. Only called by abac_graph_add_credential.
- */
-static abac_vertex_t *_get_intersection_vertex(abac_graph_t *graph, abac_credential_t *cred) {
-    abac_role_t *role, *tail_role;
-    abac_vertex_t *vertex;
-
-    abac_list_t *prereqs = abac_credential_prereqs(cred);
-    char *string = _prereq_key(prereqs);
-    HASH_FIND_STR(graph->vertices, string, vertex);
-
-    // add the vertex if it doesn't exist
-    if (vertex == NULL) {
-        vertex = abac_xmalloc(sizeof(abac_vertex_t));
-        vertex->role = NULL;
-        vertex->name = string;
-
-        // create the list of edges
-        vertex->edges = abac_list_new();
-
-        // for intersections, will be populated first time it's created
-        vertex->prereqs = abac_list_new();
-
-        // add each prereq to the vertex
-        abac_list_foreach(prereqs, tail_role,
-            abac_vertex_t *tail_vertex = _get_vertex(graph, tail_role);
-            abac_list_add(vertex->prereqs, tail_vertex);
-        );
-
-        // add it to the vertices
-        HASH_ADD_KEYPTR(hh, graph->vertices, vertex->name, strlen(vertex->name), vertex);
-    }
-    else
-        free(string); // already exists, get rid of useless memory
-
-    return vertex;
-
 }
 
@@ -203,12 +140,5 @@
 
     head_vertex = _get_vertex(graph, head);
-
-    // tail is a normal role
-    if (tail != NULL)
-        tail_vertex = _get_vertex(graph, tail);
-
-    // intersection
-    else
-        tail_vertex = _get_intersection_vertex(graph, cred);
+    tail_vertex = _get_vertex(graph, tail);
 
     // make sure we don't insert the same edge twice (ugh)
@@ -239,6 +169,6 @@
 
     abac_list_foreach(traversal, vertex,
-        if (vertex->role != NULL && abac_role_is_principal(vertex->role))
-            abac_set_add(principals, vertex->name);
+        if (abac_role_is_principal(vertex->role))
+            abac_set_add(principals, abac_role_string(vertex->role));
     );
 
@@ -297,5 +227,5 @@
     for (vertex = graph->vertices; vertex != NULL; vertex = vertex->hh.next) {
         // intersection
-        if (_vertex_is_intersection(vertex)) {
+        if (abac_role_is_intersection(vertex->role)) {
             // for each prereq edge:
             //     find principals that have the edge
@@ -326,6 +256,4 @@
                 abac_vertex_t *principal = _find_vertex(graph, name);
                 _derived_edge(graph, vertex, principal);
-
-                printf("adding edge from %s to %s\n", principal->name, vertex->name);
             );
 
@@ -395,5 +323,5 @@
 
     // don't revisit nodes
-    if (!abac_set_add(seen, vertex->name))
+    if (!abac_set_add(seen, abac_role_string(vertex->role)))
         return;
 
@@ -476,17 +404,15 @@
     abac_list_foreach(traversal, vertex,
         abac_role_t *role = vertex->role;
-        char *vertex_name = vertex->name;
 
         abac_list_foreach(vertex->edges, incoming,
             abac_role_t *incoming_role = incoming->vertex->role;
-            char *incoming_name = incoming->vertex->name;
-
-            if (!abac_set_contains(on_path, incoming_name))
+
+            if (!abac_set_contains(on_path, abac_role_string(incoming_role)))
                 continue;
 
-            abac_set_add(on_path, vertex_name);
+            abac_set_add(on_path, abac_role_string(role));
 
             // get implying edges for intersection vertices
-            if (_vertex_is_intersection(vertex)) {
+            if (abac_role_is_intersection(role)) {
                 abac_vertex_t *prereq;
                 abac_list_foreach(vertex->prereqs, prereq,
