• Keine Ergebnisse gefunden

Graphs and classic graph problems

N/A
N/A
Protected

Academic year: 2022

Aktie "Graphs and classic graph problems"

Copied!
8
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

§  Encoding of graphs: edge lists, adjacency lists, node-edge incidence matrix adjacency matrix

– edge list

§  If G=(V,E) is a graph with n=|V| nodes and m=|E| edges, the edge list will look as follows:

n,m,{a1,e1},{a2,e2},...,{am,em}, with {ai,ei} are end nodes of edge i

§  The sequential arrangement of edges within the list is arbitrary

§  {v,v} is inserted for a loop

§  In directed graphs, the first edge component marks the start node, the other one the end node

24.05.12 | Komplexität | 59

Graphs and classic graph problems

(2)

Example:

edge list: 4,6,{v

1

,v

2

},{v

2

,v

4

},{v

4

,v

4

},{v

3

,v

4

},{v

2

,v

3

},{v

3

,v

1

}

24.05.12 | Komplexität | 60

Graphs and classic graph problems

v4 v3

v2 v1

(3)

24.05.12 | Komplexität | 61

c(e)=3

Graphs and classic graph problems

Edges may be supplied with weights or costs. I.e., there is a cost function c: E → Q

Encoding: weights for the edges are noted.

An edge list consumes 2m+2 memory cells for storeing, an edge list with weights 3m+2 cells.

(4)

§  Graph coding: edge lists, adjacency matrizes, node-edge incidence- matrizes, adjacency lists

– Adjacency matrix

§  Let G=(V,E) be a simple graph (i.e. no more than one edge per node pair) with nodes 1,...,n. Then, the matrix A∈IRn×n with

§  Aij = 1, if (i,j) is an edge,

§  Aij = 0 , otherwise

is called the adjacency matrix of G.

§  If A has edge weights, then we set Aij = c((i,j)), if (i,j)∈E; and Aij = 0, +∞, oder -∞ otherwise, depending on the task.

§  Memory consumptions is O(n2) cells.

24.05.12 | Komplexität | 62

Graphs and classic graph problems

(5)

Examples:

Adjacency matrix:

24.05.12 | Komplexität | 63

Graphs and classic graph problems

v4 v3

v2 v1

0 1 1 0 1  0 1 1 1 1 0 1 0 1 1 1

v4 v3

v2 v1

0 1 1 0 0 0 1 0 0 0 0 0 0 1 1 1

(6)

§  Graph coding: edge lists, adjacency matrizes, node-edge incidence- matrizes, adjacency lists

– node-edge-incidence matrix

§  Let G=(V,E) be a simple directed graph with the nodes 1,...,n. The matrix A∈ {-1,0,1}|V|×|E| with

§  Aij = 1, if edge j leaves node i,

§  Aij = -1, if edge j directs into node i,

§  Aij = 0 otherwise

is called node-edge-incidence matrix of G.

§  Memory consumption: O(|V|⋅|E|) cells.

24.05.12 | Komplexität | 64

Graphs and classic graph problems

(7)

Examples:

node-edge-incidence matrix:

24.05.12 | Komplexität | 65

Graphs and classic graph problems

1 1 0 0 0 -1 0 1 -1 0 0 -1 -1 0 -1 0 0 0 1 1

v4 v3

v2 v1

v1 v2

v1 v3

v4 v2 v2 v3

v4 v3 v1

v2 v3 v4

(8)

§  Graph coding: edge lists, adjacency matrizes, node-edge incidence- matrizes, adjacency lists

– Adjacencyliste

When we store the number of nodes for a graph G=(V,E) plus the degree and the neighbours of each node , such a data structure will be called an adjecency- list of G.

Memory consumtion: O(|V| + |E|).

24.05.12 | Komplexität | 66

Graphs and classic graph problems

v4 v3

v2

v1 #nodes No. of node degree neighbour

4 1 2 2,3

2 3 1,3,4

3 3 1,2,4

4 3 2,3,4

Referenzen

ÄHNLICHE DOKUMENTE

Claim: A necessary and sufficient condition for a walk of the desired form is that the graph is connected and has exactly zero (-> Eulerian cycle) or two nodes (->

In this paper we initiate the study of the Roman (k, k)-domatic number in graphs and we present sharp bounds for d k R (G).. In addition, we determine the Roman (k, k)-domatic number

We present the Creative Exploration Toolkit (CET), which consists of a state-of-the-art user interface for graph visu- alization designed towards explorative tasks and support tools

We study the number of minimal codewords in binary linear codes that arise by appending a unit matrix to the adjacency matrix of a graph..

1 Department of Radiology, Charité – Universitätsmedizin Berlin, corporate member of Freie Universität Berlin, Humboldt-Universität zu Berlin, and Berlin Institute of

Previous experimental research has shown that such models can account for the information processing of dimensionally described and simultaneously presented choice

Hint: Assume that this is false and bound the number of remaining edges from below. 3 The bounds derived here are stronger than those in the lecture, but more unwieldy. For

d) Assuming an MST of the terminal graph is already constructed and a corresponding edge set is already known (in the sense that nodes know their incident edges in this set), can