Assignment 4 in a Nutshell
Assignment 4 – The Follow Relation of Twitter
Learning Outcomes:
- You will be able to:
- You will be able to represent Graphs using object-oriented concepts.
- You will be able to implement common data structures like LinkedLists, Stacks and Queues and develop them using Java Generics.
- You will be able to implement search operations on Graphs using algorithms such as Breadth-First Search (BFS) and Depth-First Search (DFS) and understand the difference between BFS and DFS.
- You will be able to understand and verify key mathematical properties of Graphs such as reflexive, symmetric, transitive.
- You will be able to compute the equivalence class of Twitter users from the provided graph, when it represents an equivalence relation.
- You will be able to improve your understanding of unit testing with JUnit. You will be able to practice inheritance, encapsulation, and polymorphism.
- You will be able to read and understand some pre-developed code and extend it, which is a key learning outcome for software developers.
Javadoc for Assignment 4
Please click the following link to explore the application programming interface (API) of this assignment: A4 API
The Assignment Handout
The handout can be obtained as a PDF document by using the following link: The A4 Handout
FAQ
-
Question: In the method
isReflexive(set, relation)what isset, relation?Answer:
setdenotes the set of vertices in the graph, where each vertex is represented as aString. Likewise,relationis the set of edges in the graph, where each edge is represented as a string of the form"a,b", whereadenotes the source vertex andbdenotes the destination vertex. Both thesetand therelationare passed as aList<String>by invoking the methodtweetGraph.isReflexive(graphUI.getSetElements(), graphUI.getRelationElements()in the controller. This also applies to the parameters of theisEquivalencemethod.Likewise, the above applies to the parameter
relationused in the methodsisSymmetricandisTransitive. -
Question: Does the order of the elements in
List<String>returned by theisEquivalencemethod important?Answer: This is answered in the Piazza handle @585. Specifically, as this represents a
Set, the order is unimportant. Test cases will be updated based on this. -
Question: Can we import custom classes?
Answer: Yes, as long as you have designed and implemented these classes. These classes also shouldn’t import
java.util.*. -
Question: Do we have to use
adjacencyMapfor implementing the methodsisReflexive, isSymmetric, isTransitive?Answer: We have answered this in question 1 above. The answer is NO.
-
Question: Do we need to check for the correctness of the input files in the dot format i.e. that the graph doesn’t have duplicate vertices / edges etc. Refer to the response to the Piazza post @587.
Answer: For this assignment we will assume that you are always given the correct input file and you don’t need to write extra tests / exceptions for this.
-
Question: How is the graph represented in the assignment?
Answer: The graph is represented using the
adjacencyMapin the classGraph. This map associates everyNode<String>in the graph, which is associated with the list of outgoing edges from a specified node. This list of outgoing edges is represented as aLinkedList<Edge<Node<String>>>. NOTE that eachEdgeobject has a source and a destination node. TheEdge<Node<String>>is only representing the type of anEdge. -
Question: In the method
searchTweet()for Task 4 should we use BFS or DFS? Refer to post @580.Answer: Using BFS and DFS will result in different answers. So, we will require you to only use DFS, for implementing this method.
-
Question: For the command
search-tweet user-idfor Task 4, what should we return? Refer to the post @580.Answer:
searchTweetsearches for the givenkeywordstarting from a specified user i.e. TwitterHandle object. Note that the answer may be different using BFS or DFS. In our test-cases we use DFS only.Essentially, you are already given a map that associates a List of Tweets with any given TwitterHandle. You start your search from the specified user and stop when either the user or a successor has a tweet containing the keyword. For determinism, the first occurrence of the user that matches the search criteria is returned.
T4_03_C is incorrect. We will update this.
-
Question: For the command
search-tweet user-idfor Task 4, what happens when the user-id given is not connected by any path to a successor user, which contains aTweetwith the givenkeyword?Answer: In that case, as the the successor user is unreachable, the result should be
No successor of " + user.getName() + "tweeted " + tweetKeyword. -
Question: For the command
search-tweet user-idfor Task 4, what happens when thekeywordis a substring of a given word in theTweet?Answer: In that case, the
Tweetis returned successfully. -
Question: Can I use available data-structures from the Collections Framework?
Answer: NO. You are required to implement the data-structures in the package
ds. -
Question: How do I update the latest files from Canvas to update the new terminal commands, the revised JSON file and the signature change to the depthFirstSearch method?
Answer: Please follow the steps below for these changed files. The overall time taken to incorporate these changes should be less than 15 minutes in total. This is a conservative estimate. Please note that incorporating these changes, including any revisions to your code if you have made significant progress, only affects 1% of the final marks.
-
First open the file to be replaced i.e. say
GraphControl.javaboth the old and the new version. Every one has to replace the following files:GraphControl.java, GraphUI.java, Tweets.json. - Go to step 3 if you have cloned but not started. This step is for the students who have cloned and started on the assignment will, in addition, also need to do the following:
- Copy the method
getTweetsText()forTweetGraph.java. - Update the method signature for the method
depthFirstSearch()inGraph.java. - Go to step 4.
- Copy the method
-
Open the files
TweetGraph.java, Graph.javaadditionally to step 1. -
Copy the new version and replace the old version with the new for the files opened in steps 1, 3 ONLY.
-
Delete and replace
TestsForMarking.javawithStudentsTestForMarking.java. -
Note that the
bestFirstSearchmethod’s signature has also changed. However, it is optional for you to update this revised method. This is since we only use DFS for thetweetSearch. The outcome of the test cases will be invariant to your decision. - If you have any further queries with these steps best to see Aron on the Friday lab session this week or email him if you can’t.
-
