Difference between revisions of "Graphs"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Comparison of List VS Matrix)
Line 1: Line 1:
 +
[[File:Graph-4.jpg|300px|thumb|right]]
 +
 
==What is a graph==
 
==What is a graph==
 
[[File:Graph-1.jpg|thumb|200px]]
 
[[File:Graph-1.jpg|thumb|200px]]

Revision as of 20:37, 26 November 2017

Graph-4.jpg

What is a graph

Graph-1.jpg

A graph is an abstract data structure. It can be used to solve routine problems.

Vertices connected by an edge (see picture) are called Neighbours.

The degree of a vertex is how many things are connected to it, in the picture, there would be 2.

Edges can also be called connectors and vertex can also be called nodes or entries.

Terms

weighted graph

vertex/node

edge/arc

undirected graph

directed graph

Adjacency Matrix

Graph-2.jpg

An adjacency matrix is a list showing the what vertexes are connected to their neighbors. This is represented by a list showing what vertex is connected to the other.






Adjacency List

Graph-3.jpg

This is a list shown in binary for the values that are going to be connected. It usually helps to transfer the matrices into a list first before you turn it into a graph to make things easier.






Comparison of List VS Matrix

Matrix List
Its quicker to find an edge Needs to look at all items
Less space, no wastage Stores information about each edge