c++ exercise and need the explanation and answer to help me learn.
Write a C++ program that reads the Financial Transaction graph , represent it using
adjacency lists and finally print the adjacency list. For this recitation, you are supposed
to create two structures/classes
(1) Edge : All elements or nodes in the adjacency list represent distinct edges.
Each edge object contains three members: the destination vertex, the weight of the
edge and address of the next edge in the linklist. Note, we do not require source
vertex as the edge should be inserted in the linklist corresponding to the source
vertex.
(2) Graph : The graph should contain the number of vertices and an array of linklists.
The length of the array of linklist should be equal to the number of vertices
please see the attached file to understand all
Requirements:
Recitation 5 The objective of this recitation is to read a weighted graph and represent it in form of an Adjacency List.
Imagine you want to model a network of Þnancial transactions between bank accounts. In this network, each account is represented as a vertex, and the Þnancial transactions (money transfers) between accounts are represented as weighted directed edges. The weight on each directed edge can represent the amount of money transferred and the direction of the transaction (e.g., debit).
For example:
¥Vertices (Bank Accounts): A, B, C, D, E
Weighted Directed Edges (Financial Transactions):
¥A to B: $1,000 (debit from A to B)
¥B to C: $500 (debit from B to C)
¥C to D: $300 (debit from C to D)
¥D to E: $600 (debit from D to E)
¥E to A: $200 (debit from E to A)
¥E to C: $400 (debit from E to C)
In this weighted directed graph, the numerical values represent the amount of money transferred, and the direction of the edge indicates the direction of the transaction (e.g., from A to B). This graph can be used to track Þnancial ßows, detect unusual transaction patterns, or analyze the movement of funds within the network.
An adjacency list is a common way to represent a graph data structure. It’s a collection of linklists used to describe which vertices (or nodes) are adjacent to each vertex in a graph. Each vertex in the graph has a list of its neighboring vertices. In the case of a directed graph, each entry in the adjacency list represents outgoing edges from a vertex
Below we represent the above graph in form of an adjacency list.
A : B/1000 Ñ> Null
B : C/500 Ñ> Null
C : D/300 Ñ> Null
D : E/600 Ñ> Null
E : C/400 Ñ> A/200 Ñ> Null
Format of the Graph You are to read in an edge weighted graph G = (V, E, w) from a text Þle named Ôgraph.txtÕ. The format of the input Þle containing the graph is as follows. The Þrst line in the Þle contains two positive integers:
n m
where n is the number of vertices and m is the number of edges.
Each of the next n lines has a string representing the bank account.
Each of the next m lines has three space separated Þelds of the form:
You must represent G using adjacency lists (i.e. linklist). Therefore, when you read the value of n, you should initialize an array of pointers of size n for the adjacency list for each vertex. As you read each edge, you should insert it into the appropriate adjacency list, at the front of the list. For a given edge [u, v], the node ÔvÕ is inserted into vertex uÕs adjacency list.
Write a C/C++ program that reads the Financial Transaction graph , represent it using adjacency lists and Þnally print the adjacency list. For this recitation, you are supposed to create two structures/classes
(1)Edge : All elements or nodes in the adjacency list represent distinct edges.
Each edge object contains three members: the destination vertex, the weight of the edge and address of the next edge in the linklist. Note, we do not require source vertex as the edge should be inserted in the linklist corresponding to the source vertex.
(2)Graph : The graph should contain the number of vertices and an array of linklists. The length of the array of linklist should be equal to the number of vertices
Sample input Ñ-> Ôgraph.txtÕ. We have also uploaded Ôgraph.txtÕ in module for reference.
Content of Ôgraph.txtÕ
5 6
A
B
C
D
E
B A 1000
C D 300
B C 500
D E 600
E A 200
E C 400
Expected Output A : Null
B : C/500 Ñ> A/1000 Ñ> Null
C : D/300 Ñ> Null
D : E/600 Ñ> Null
E : C/400 Ñ> A/200 Ñ> Null
Note:
1.You should dynamically allocate memory for edges in the linklist.
2.Do not use vector or arrays to create edges in your adjacency list.
We are a professional custom writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework.
Yes. We have posted over our previous orders to display our experience. Since we have done this question before, we can also do it for you. To make sure we do it perfectly, please fill our Order Form. Filling the order form correctly will assist our team in referencing, specifications and future communication.
1. Click on the “Place order tab at the top menu or “Order Now” icon at the bottom and a new page will appear with an order form to be filled.
2. Fill in your paper’s requirements in the "PAPER INFORMATION" section and click “PRICE CALCULATION” at the bottom to calculate your order price.
3. Fill in your paper’s academic level, deadline and the required number of pages from the drop-down menus.
4. Click “FINAL STEP” to enter your registration details and get an account with us for record keeping and then, click on “PROCEED TO CHECKOUT” at the bottom of the page.
5. From there, the payment sections will show, follow the guided payment process and your order will be available for our writing team to work on it.
Need help with this assignment?
Order it here claim 25% discount
Discount Code: SAVE25