public static <E extends Edge, G extends Graph<E>> Graph<Edge>
toLineGraph(G graph, Indexer<E> edgeIndices) {
Graph<Edge> lineGraph = new SparseUndirectedGraph();
IntIterator verts = graph.vertices().iterator();
while (verts.hasNext()) {
int v = verts.nextInt();
Set<E> adjacent = graph.getAdjacencyList(v);
// For each pair of edges connected to the same vertex, add them as
// vertices in the line graph and connect them by an edge
for (E e1 : adjacent) {
int e1vertex = edgeIndices.index(e1);