Develop a program to read simple undirected connected graphs into an n x n 2D array.

CMPS 2433 – Discrete Constructions and Assessment

Program four

Due December four, 2018

Downside: Write a program to read simple undirected connected graphs into an n x n 2D array. Then

decide whether or not that graph has an Euler Circuit utilizing the algorithm described beneath. If the graph has

an Euler circuit, discover one and print out the nodes within the Euler Circuit. If the graph doesn’t have one,

print NO EULER CIRCUIT EXISTS.

Methodology: First your program should decide if the connected graph enter and saved within the 2D array has

an Euler Circuit. A graph that has vertices of all even diploma comprises an Euler Circuit. Second, if the

graph does have one, then your program should discover an Euler Circuit within the graph utilizing a modification of

Fleury’s algorithm.

Fleury’s algorithm, revealed 1883 constructs Euler subcircuits by first selecting an arbitrary vertex (say

zero) of a graph, and kinds a circuit by selecting edges successively. As soon as an edge is chosen, it’s eliminated.

Edges are chosen successively so that every edge begins the place the final edge ends, and in order that this edge

just isn’t a reduce edge, until there is no such thing as a various. The algorithm terminates when the unique vertex (zero) is

reached. If there aren’t any edges remaining within the graph, then the trail has the constructed Euler circuit,

in any other case it has solely discovered a subcircuit. Simply cease there and print out a message that solely a subcircuit

was discovered.

Essential Notes:

 You could use arrays or vectors on this program.

 In the event you use arrays, you will need to dynamically allocate reminiscence for every array and correctly unencumber

that reminiscence while you end processing that specific graph (array).

 You could write features to

o Open the enter and output recordsdata

o Read within the graph’s edges

o Decide if a graph has an Euler Circuit

o Discover and print an Euler Circuit utilizing Fleury’s algorithm

o Decide if a graph has edges

 There is not going to be greater than 20 vertices.

 Vertices are labelled zero, 1, 2, …

Enter File: connected2D.dat

Pattern enter file: three //variety of take a look at circumstances

6 //variety of rows and columns within the 2D array

zero 1 zero zero zero 1 //values within the 2D array

1 zero 1 zero zero zero //DRAW the GRAPH on the enter file

zero 1 zero 1 1 1

zero zero 1 zero 1 zero

zero zero 1 1 zero 1

1 zero 1 zero zero zero

four //variety of rows and columns within the 2D array

zero 1 1 1 //values within the 2D array

1 zero 1 1 //DRAW the GRAPH on the enter file

1 1 zero 1

1 1 1 zero

7

zero 1 zero 1 zero zero zero

1 zero zero 1 zero zero zero

zero zero zero 1 1 zero zero

1 1 1 zero 1 1 1

zero zero 1 1 zero zero zero

zero zero zero 1 zero zero 1

zero zero zero 1 zero 1 zero

Output File: lastname_prog4.txt

Pattern output file: Joanna Wringer

Euler Circuit: There are three Graphs

GRAPH 1

zero 1 2 three four 2 5 zero

EULER CIRCUIT CONSTRUCTED

GRAPH 2

NO EULER CIRCUIT EXISTS

GRAPH three

zero 1 three zero

A SUBCIRCUIT CONSTRUCTED

Published by
Essays
View all posts