Thursday, August 21, 2014

Graphs and Hypergraphs

Graph :- A graph G is an 2-tuple (V,E) of a set of vertices V and a set of edges E, where {x,y} ∈ E  ⇒ x,y ∈ V.


Directed Graph :- A directed graph is an 2-tuple (V,E) of a set of vertices V and a set of edges E, where (x,y) ∈ E  ⇒ x,y ∈ V.

Each of above, can be further classified into, labeled and unlabeled classes.

 
Labeled simple Graph of 6 vertices and 7 edges
An un-labeled Directed Graph
Graphs, can further be classified as edge or vertex or both weighted graphs. So, weighted graphs is represented by G(V,E,w(V),w(E)), where w resembles weight. 

Computer Representation of Graph :-

w(V) is an array of numbers w0,w1,...,wn-1
w(E) is an 2-D array of numbers, called Adjacency Matrix A = ( w(x,y) ) where w(x,y) is the weight of edge (x,y) ∈ E. If edge is not present then w(x,y) = 0.

We can also, represent w(E) by an Adjacency List, where we have an array A, One element of A is another array A(x), which contains, ordered pair (w(x,y), y) sorted with respect to y.




This representation ease the search of edge as well as reduce the storage space in the sparse graph. 

Note, that Adjacency List search time is O(log(n)), space complexity O(|V| + |E|). In Adjacency Matrix search time is O(1) but space complexity is O(|V|2).



Adjacency List Representation of directed and undirected graphs


















Again Hypergraph is a graph in which each edge is a k-tuple or set of k vertices, where k ≤ |V|. 

No comments:

Post a Comment