Skip to content

Commit 93feb6f

Browse files
Create readme.md
1 parent 633f83c commit 93feb6f

File tree

1 file changed

+21
-0
lines changed
  • src/main/java/es/uniovi/data_structures/graph

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Graph
2+
A graph is a diagram showing the relation between variable quantities, typically of two variables, each measured along one of a pair of axes at right angles.
3+
4+
![](https://github.com/computer-science-uniovi/java-algorithms/blob/master/src/main/java/es/uniovi/data_structures/graph/graph-def-7.png)
5+
6+
For example in the avobe picture shows the nodes 1 2 3 4 and 5, the number in the edge (line that links two nodes) is the weight or the cost to pay to cross that path. Example, to go from 1 to 2 we can go directly with a cost of 2, or through 4 paying 5 + 5 = 10. Here we just discover the problem of minimum cost paths. But first lets specify how we will represent the graph in java.
7+
8+
## Node class
9+
A node just has to store its content and a boolean value to indicate wheter it has been visited or not. This visited value bill be used later for minimum cost paths problems resolution.
10+
11+
```java
12+
public class Node<T> {
13+
T content;
14+
boolean visited;
15+
}
16+
```
17+
18+
## Graph class
19+
The graph class will be a collection of nodes with relations between them and costs (weights) for the relations between them (paths). For that porpouse we will use a list to store the nodes, and two matrices, one for the paths and another for the weights.
20+
21+

0 commit comments

Comments
 (0)