#include <stdlib.h>
#include <LINK/graph/Graph.h>
#include <LINK/graph/UBinGraph.h>
#include <LINK/graph/Vertex.h>
#include <LINK/graph/Edge.h>
#include <LINK/algorithm/DepthFirstSearch.h>
    
//
// Generate a Halin graph given a tree with interior nodes of degree >=3
// If g doesn't meet these criteria, execute the same process anyway
// (result isn't a Halin graph, but might be interesting)
//

int clockwise(Vertex* v1, 

MUBinGraph*
GenHalinGraph(Graph *g)
{
    MUBinGraph*  graph = new MUBinGraph(g, CLONE); 
    const SortedArray<Vertex*>& vertices = graph->vertices();
    int num_vertices = graph->order();
    if (p < 0.0 || p > 1.0) {
	warning("GenRandomGraph(): bad edge probability, using 0.0");
	p = 0.0;
    }
    Set<Vertex*> s;  
    for (int i=0; i < num_vertices; i++) {
    	for (int j=i+1; j < num_vertices; j++) {
		if (Link_randomDouble0_1() < p) {
			s.insert(vertices[i]);
			s.insert(vertices[j]);
		        Edge* edge = graph->addEdge(s);
			s.clear();
		}
	}
    }
    return graph;
}
