reset password
Author Message
hal255
Posts: 51
Posted 17:21 Oct 26, 2014 |

For the Node class, should the NEXT contain a NODE? or a LIST of nodes? I feel it should contain a list of nodes but wanted to make sure.

Reasoning: if multiple nodes connect to the starting node S, then S.next would have multiple nodes.

rabbott
Posts: 1649
Posted 17:23 Oct 26, 2014 |
How are you handling edges?
hal255
Posts: 51
Posted 17:32 Oct 26, 2014 |

I used the user inputs to get the edges, since it said "Assume the input is given as a sequence of edges".

Input 1 is node1, Input2 is node2. node1.next points to node2.head. 

Edge contains 2 nodes, my reasoning was because it was supposed to connect two nodes, thus it should hold 2 nodes. Though I have a feeling this is where I've gone wrong.

rabbott
Posts: 1649
Posted 17:39 Oct 26, 2014 |
I'm not following what you're saying. Does the representation of the graph include both nodes and edges? The matrix representation has no explicit edge objects but the list representation should.
hal255
Posts: 51
Posted 17:50 Oct 26, 2014 |

I created an Edge class, which contains the two nodes it is in "connection" with.

I created an edgeList which is of type LinkedList<Edge> that stores a list of "connections" of any 2 given nodes.

Basically, the edgeList contains all the user inputs.

vsluong4
Posts: 87
Posted 22:11 Oct 26, 2014 |

I believe the video suggested that each Vertex contains all edges it is incident with

 

Here's how I coded it

Vertex

-name:String

-eList:List<Edge>

+Vertex(String)

Edge

-tail:Vertex

-head:Vertex

+Edge(Vertex, Vertex)

Last edited by vsluong4 at 23:32 Oct 26, 2014.