예제 #1
0
int main(int argc, char **args)
{
	s_graph graph;
	graph_init(&graph, 6);

	for (int i = 0; i < 6; i++)
	{
		graph_set_vertex(&graph, i, i);
	}

	graph_set_arccell(&graph, 0, 2, 10);
	graph_set_arccell(&graph, 0, 4, 30);
	graph_set_arccell(&graph, 0, 5, 100);
	graph_set_arccell(&graph, 1, 2, 5);
	graph_set_arccell(&graph, 2, 3, 50);
	graph_set_arccell(&graph, 3, 5, 10);
	graph_set_arccell(&graph, 4, 3, 20);
	graph_set_arccell(&graph, 4, 5, 60);

	graph_display(&graph);

	graph_shortest_path(&graph);

	graph_destroy(&graph);

	return 0;
}
예제 #2
0
int main(int argc, char **args)
{
	s_graph graph;
	graph_init(&graph, 5);

	for (int i = 0; i < 5; i++)
	{
		graph_set_vertex(&graph, i, i);
	}

	graph_set_arccell(&graph, 0, 1, 15);
	graph_set_arccell(&graph, 1, 4, 71);
	graph_set_arccell(&graph, 1, 3, 23);
	graph_set_arccell(&graph, 3, 4, 42);
	graph_set_arccell(&graph, 2, 4, 36);
	graph_set_arccell(&graph, 2, 0, 27);
	graph_set_arccell(&graph, 3, 3, 61);
	graph_set_arccell(&graph, 2, 1, 92);

	graph_display(&graph);

	graph_destroy(&graph);

	return 0;
}
예제 #3
0
void main() {
    int i, j, k1, k2, w, count;
    Set *s_visited;
    Graph *g = init_graph(10);
    for(i = 0; i < 10; i++) {
        k1 = (int) rand() % 10;
        k2 = (int) rand() % 10;
        w = (int) rand() % 100 + 1;
        add_edge(g, k1, k2, w);
    }
    graph_display(g);
    mst_krushkal(g);
}
예제 #4
0
파일: dfs.c 프로젝트: arshadansari27/aoa
void main() {
    int i, j, k1, k2, w, count;
    Set *s_visited;
    Graph *g = init_graph(10);
    for(i = 0; i < 10; i++) {
        k1 = (int) rand() % 10;
        k2 = (int) rand() % 10;
        w = (int) rand() % 100 + 1;
        add_edge(g, k1, k2, w);
    }
    graph_display(g);
    s_visited = set_create();
    printf("Depth first traveral\n***********************\n");
    depth_first_traversal(g, 0, s_visited);
}