c++ how do i create a adjacency matrix from 2 files

i have a program to calculate the MST using prims algorithm but the only way i have it working is if the input is the actual adjacency matrix. the input we are given is 2 files. 1 for the verticies and 1 for the edges. how can i turn those into a adjacency matrix? here is sample input for the files. my question is how can i turn those 2 files into the matrix i need so my input will come from the files instead of me hardcoding it in

Verticie file
3 (number of vertices)
V128.8.10.14 (vertex identifier)
V128.8.128.423
V128.8.10.268

Edge file
2 (number of edges)
V128.8.10.14 V128.8.10.268 43.56 (endpoints and edge weight)
V128.8.10.268 V128.8.128.423 170.36

below is how im implementing it now for my program to run any help or hints would be great. thanks
1
2
3
4
5
6
7
8
9
10
11
 int graph[V][V] = { { 0, 2, 0, 6, 0, 0},
						{ 2, 0, 3, 8, 5, 0},
						{ 0, 3, 0, 0, 7, 0},
						{ 6, 8, 0, 0, 9, 0},
						{ 0, 5, 7, 9, 0, 3},
						{ 0, 5, 7, 9, 3, 0},
					};

	MST(graph);
	system("pause");
	return 0;
Last edited on
Topic archived. No new replies allowed.