faqts : Computers : Programming : Algorithms : Datastructure : Graph

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 7 people (71%) answered Yes
Recently 5 of 7 people (71%) answered Yes

Entry

Datastructure: Graph: Presentation: Adjacency: Matrix: Node: How use table to show to connections?

Jan 15th, 2005 11:48
Knud van Eeden,


----------------------------------------------------------------------
--- Knud van Eeden --- 15 January 2005 - 07:45 pm --------------------

Datastructure: Graph: Presentation: Adjacency: Matrix: Node: How use 
table to show connections?

---

A graph may be represented by an adjacency matrix (e.g. using a
rectangular array with rows and columns) or a linked list (e.g. using
an array with a fixed amount of rows and a variable amount of columns).

---

Graph: Presentation: ADJACENCY matrix (this is an NxN matrix)

---

Create a table or thus an array, and put the points in the rows and
also in the columns. So you get a square array. In the elements
you write a '0' if no connection, and a '1' if a connection line.

---

+------------+---------+---------+---------       +------------+
|            |  node 1 |  node 2 | node 3  ...    |node last   |
+------------+---------+---------+---------       +------------+
|node 1      |   0     |   1     |          ...   |     1      |
+------------+---------+---------+---------       +------------+
|node 2      |   1     |   1     |          ...   |     0      |
+------------+---------+---------+---------       +------------+
|node 3      |   1     |   0     |          ...   |     0      |
+------------+---------+---------+---------       +------------+
|...         |         |         |          ...   |     1      |
+------------+---------+---------+---------       +------------+
|node last   |   0     |   1     |          ...   |     1      |
+------------+---------+---------+---------       +------------+

---
---

Note:

-a 0 means NO connection betweens these two nodes
-a 1 means a connection betweens these two nodes

---
---

Internet: see also:

---

Datastructure: Link: Overview: Can you give an overview of links?
http://www.faqts.com/knowledge_base/view.phtml/aid/32054/fid/1264

----------------------------------------------------------------------