homework #5 due: october 31, 2000 christine kang graph concepts and algorithms

28
Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Upload: edgar-campbell

Post on 06-Jan-2018

213 views

Category:

Documents


0 download

DESCRIPTION

Multiple Edges Multiple edges occur when there is more that one edge between two nodes. This illustration shows two edges between two of the graph’s nodes.

TRANSCRIPT

Page 1: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Homework #5Due: October 31, 2000

Christine Kang

Graph Concepts and Algorithms

Page 2: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Vertices and Edges• The circles are vertices.• The lines in between the

vertices are called edges.• Vertices do not have to be

connected to one another in order to be part of a graph.

• Edges do not have to connect two or more vertices. In fact, they may be redirected to one vertex thereby creating a loop.

Page 3: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Multiple Edges

• Multiple edges occur when there is more that one edge between two nodes.

• This illustration shows two edges between two of the graph’s nodes.

Page 4: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Loops

• A loop is when a vertex has an edge going to itself.

• The node on the far upper left has a loop coming from itself.

Page 5: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Undirected Graph

• An undirected graph is one in which the edges have no one specific direction in which they are reaching. (no arrows pointing to a specific direction on the edges).

Page 6: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Directed Graph (Digraph)

• A directed graph, on the other hand, does have specific directions of travel shown on each edge. (these directions are depicted by arrows).

Page 7: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Simple Graph

• A simple graph is one in which there are no loops and there are no multiple edges.

Page 8: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Graph versus...

• This is a graph.• The way it differs

from a multigraph is that...

Page 9: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Multigraph

• A multigraph may have loops and/or multiple edges.

Page 10: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Special Classes of Graphs

• Complete Graphs• Bipartite Graphs

Page 11: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Complete Graphs

• A complete graph is one in which there are n nodes and O(n^2) edges.

• All possible edges between nodes are represented in this graph.

Page 12: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Bipartite Graph

• A bipartite graph is a graph that can be split in half and does not have edges between vertices in the same class.

Page 13: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Path in an Undirected Graph

• Take this graph for example.

• A path in this Graph is simply a subgraph that has no cycles, is connected and each vertex is connected to one or two other nodes.

Page 14: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Path in an Undirected Path

• A path would therefore look like this.

Page 15: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Path in an Undirected Graph

• This is not a path because the middle node on the left has more than one or two edges coming from it.

• A path need not cover all points.

Page 16: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Path in a Directed Graph

• Take this graph for an example…

• A path in a digraph has one vertex with an in-degree of 0 and one vertex without an out-degree of 0 and the others have in-degree 1 and out-degree 1.

Page 17: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Path in a Directed Graph

• Therefore, this is a path in the directed graph. Notice that it has 1 vertex with in-degree 0, 1 vertex with out-degree 0, and the others have in-degree 1 and out-degree 1.

• A path need not cover all points.

Page 18: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Hamiltonian Path in an Undirected Graph

• This is a Hamiltonian path in an undirected graph.

• It is a path that covers (or spans) all the vertices.

Page 19: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Hamiltonian Path in a Digraph

• This is a Hamiltonian path in a Digraph.

• Notice that all nodes are covered and that the selected edges of the graph follow the original direction and still cover all nodes.

Page 20: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Cycle in an Undirected Graph

• A cycle in an undirected graph is a subgraph that is connected and each node has a degree of 2.

Page 21: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Cycle in a Directed Graph

• A cycle in a digraph occurs in the same way as one occurs for an undirected graph. It will be the same thing for a directed graph.

Page 22: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Hamiltonian Cycle in an Undirected Graph

• A hamiltonian cycle is one cycle that covers all vertices of the original graph.

Page 23: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Hamiltonian Cycle for a Digraph

• A hamiltonian cycle for a directed graph has the same definition for as for an undirected graph.

Page 24: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Spanning Forest of a graph which is not connected

• A spanning forest is a subgraph where every node is covered and

Page 25: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Cyclic Graph

• A graph is said to be cyclical id there are any cycles in the graph.

Page 26: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Acyclical Graph

• This is the same graph as before but by changing the direction of one edge we have turned this graph into an acyclical one which has no cycles in it.

Page 27: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Tree

• A tree is a graph that has at most two edges coming from a node. Each node is therefore connected to at most 2 nodes.

• The direction in a tree moves downward.

Page 28: Homework #5 Due: October 31, 2000 Christine Kang Graph Concepts and Algorithms

Forest

• A forest is made up of more than one tree.

• This example shows us two different trees.