+
+/***
+* void join_edge(struct graph_edge *e, int dir)
+* {
+* struct graph_node *other_node = NULL;
+* switch (dir)
+* {
+* case 1:
+* other_node = e->n2;
+* break;
+* case 2:
+* other_node = e->n1;
+* break;
+* // FIXME: default?
+* }
+*
+* struct graph_edge *candidate = NULL;
+* for (uns i=0; i<GARY_SIZE(other_node->edges); i++)
+* {
+* struct graph_edge *other = other_node->edges[i];
+* if (! other->visited)
+* {
+* struct graph_edge **new = GARY_PUSH(bfs_queue);
+* *new = other_node->edges[i];
+* }
+*
+* if ((!other->visited) && (e->text) && (other->text) && (e->text->text == other->text->text))
+* {
+* if (e->color == other_node->edges[i]->color)
+* {
+* if ((!candidate) || (candidate->length < other->length))
+* {
+* candidate = other;
+* }
+* }
+* else
+* {
+* // Beware: Name conflict here
+* }
+* }
+* }
+*
+* if (candidate)
+* {
+* candidate->longline = e->longline;
+* if (dir == 1)
+* {
+* if (candidate->n2 != e->n1)
+* {
+* candidate->n1 = candidate->n2;
+* candidate->n2 = e->n1;
+* }
+* e->prev = candidate;
+* candidate->next = e;
+*
+* longlines[e->longline].first = candidate;
+* }
+* else
+* {
+* if (candidate->n1 != e->n2)
+* {
+* candidate->n2 = candidate->n1;
+* candidate->n1 = e->n2;
+* }
+* e->next = candidate;
+* candidate->prev = e;
+* }
+* }
+* }
+* ***/
+
+/***
+void bfs2(void)
+* {
+* GARY_INIT(bfs_queue, 0);
+* GARY_INIT(longlines, 0);
+*
+* printf("Making longlines from %u causal lines, using %d graph edges\n", GARY_SIZE(buffer_line), num_edges_dbg);
+*
+* HASH_FOR_ALL(hash, node)
+* {
+* for (uns i=0; i<GARY_SIZE(node->edges); i++)
+* {
+* struct graph_edge *e = node->edges[i];
+*
+* // printf("Examining edge from [%.2f; %.2f] to [%.2f; %.2f]\n",
+* // e->n1->o->x, e->n1->o->y, e->n2->o->x, e->n2->o->y);
+*
+* // if (e->visited) HASH_CONTINUE; // FIXME: Is is correct?
+* if (e->visited) continue;
+* // printf("Continuing\n");
+* if (e->longline == (uns) -1)
+* {
+* GARY_PUSH(longlines);
+* e->longline = num_longlines++;
+* longlines[e->longline].first = e;
+* }
+* // printf("Longline is %u\n", e->longline);
+*
+* e->visited = 1;
+*
+* if (! e->prev)
+* {
+* join_edge(e, 1);
+* }
+* if (! e->next)
+* {
+* join_edge(e, 2);
+* }
+* }
+* }
+* HASH_END_FOR;
+*
+* GARY_FREE(bfs_queue);
+* }
+* ***/
+
+void bfs_edge(struct graph_edge *e, struct graph_node *node, struct graph_node *anode, enum edge_dir dir)
+{
+ ASSERT(dir < 3);