Java app that I made for a code challenge. It calculates the diameter of an undirected graph.
It takes a txt file in the following format:
A – B
B – C
B – D
D – E
where “A”, “B”, “C”, “D” and “E” are names of the nodes and “-” depicts a path between the nodes. Node name can be any sequence of upper case letters and numbers without spaces e.g. “A2B3”.
It then returns the diameter of the graph or if the graph is disconnected Integer.MAX_VALUE
You will need the following installed:
git clone https://github.com/ronaldnwilliams/graph-diameter-app.git
cd graph-diameter-app.git
gradle run
or to run this app with your own txt file that follows the above formatting:
gradle run --args '[some file path]'
gradle test
open build/reports/tests/test/index.html
Introduction to Programming in Java: An Interdisciplinary Aproach (2nd Edition)
by Robert Sedgewick and Kevin Wayne
Chapter 4-Algorithms and Data Structures (4.5-Case Study: Small-World Phenomenon)