Prim's Algorithm..How to identify connectivity
Hi.
I need to know how can I identify connectivity of two nodes? Please give me some hint or code to understand this.
Thanks
Prim's algorithm works over a graph, which is the structure identifying the connectivity of nodes. You must have a graph defined.
Three common ways to do it are:
- a 2D array
- a std::map (or equivalent)
- a linked list of nodes
For example, the following graph:
┌──┐
│ ↓
└─(0)←─→(1)──→(2)
↑ │
└───────────┘ |
can be described by the 2D array:
1 2 3 4 5
|
{
{ 1, 1, 0 },
{ 1, 0, 1 },
{ 1, 0, 0 }
}
| |
where row→column.
Hope this helps.
Thanks
Topic archived. No new replies allowed.