void GraphUtil::convert_weighted_graph_to_unweighted_graph(WeightedGraph& weighted_graph, UnweightedGraph& unweighted_graph)
{
    resize_graph(unweighted_graph, weighted_graph.size());
    
    for (unsigned int i = 0; i < weighted_graph.size(); ++i)
    {
        for (unsigned int j = 0; j < weighted_graph.size(); ++j)
        {
            unweighted_graph[i][j] = weighted_graph[i][j] > 0 ? 1 : 0;
        }
    }
}
Example #2
0
void add_node(graph* g, char* c) {
    unsigned int count;
	node *n;

    if (g->node_space == g->node_count) {
        resize_graph(g);
    }

	count = g->node_count;
	n = &g->nodes[count];
    n->value = c;
	n->edges = NULL;
	n->edge_count = 0;
	n->edge_space = 0;
	n->distance = INFINITY;
	n->previous = NULL;
    
    g->node_count++;
}