I am working on the following problem: I have a CSV file with two columns, we can say that the submitted names are “Friends”. Both columns contain letters from A to Z. for example.
A B
B C
A E
D F
E F
Each line has two different letters (no duplication in the line). A is a friend of B, C is a friend of D, etc. If person A is talking to person B and person B, talking to person C, then B and C will become adjacent. Aquintaces are those who have a common friend. I need to guess who has the most chords?
I tried to use two different methods, using different data structures such as hashmap, arraylist, stack, etc., and the other using graph theory (JGraphT library). But I adhere to the logic if I use data strcutres, and I adhere to the graph traversal if I use graph theory.
I have the following questions: -
- Which is better for data structures or graphics? Or any other better approach / logic / algorithm than this?
- Does anyone know how to navigate a chart in the JgraphT library. I am not able to do this, they have very limited documentation on the library.
Please any help would be really appreciated.
source
share