Discrete Structures and Analysis program(C#)
CMPS 3324 – Discrete Structures and Analysis
Program four
Due December four, 2018
Drawback: Write a program to learn easy undirected linked graphs into an n x n 2D array. Then
decide whether or not that graph has an Euler Circuit utilizing the algorithm described under. 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 linked 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, printed 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
will not be 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 will need to use arrays or vectors on this program.
In case you use arrays, you could dynamically allocate reminiscence for every array and correctly unlock
that reminiscence if you end processing that individual graph (array).
You will need to write features to
o Open the enter and output information
o Learn 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 won’t be greater than 20 vertices.
Vertices are labelled zero, 1, 2, …
Enter File: connected2D.dat
Pattern enter file: three //variety of check instances
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