Skip to content

Commit f0b5202

Browse files
Fix spelling (TheAlgorithms#2973)
1 parent 1ac1a5a commit f0b5202

File tree

1 file changed

+19
-19
lines changed
  • src/main/java/com/thealgorithms/datastructures/graphs

1 file changed

+19
-19
lines changed

src/main/java/com/thealgorithms/datastructures/graphs/Graphs.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,38 @@
44

55
class AdjacencyListGraph<E extends Comparable<E>> {
66

7-
ArrayList<Vertex> verticies;
7+
ArrayList<Vertex> vertices;
88

99
public AdjacencyListGraph() {
10-
verticies = new ArrayList<>();
10+
vertices = new ArrayList<>();
1111
}
1212

1313
private class Vertex {
1414

1515
E data;
16-
ArrayList<Vertex> adjacentVerticies;
16+
ArrayList<Vertex> adjacentVertices;
1717

1818
public Vertex(E data) {
19-
adjacentVerticies = new ArrayList<>();
19+
adjacentVertices = new ArrayList<>();
2020
this.data = data;
2121
}
2222

2323
public boolean addAdjacentVertex(Vertex to) {
24-
for (Vertex v : adjacentVerticies) {
24+
for (Vertex v : adjacentVertices) {
2525
if (v.data.compareTo(to.data) == 0) {
2626
return false; // the edge already exists
2727
}
2828
}
29-
return adjacentVerticies.add(to); // this will return true;
29+
return adjacentVertices.add(to); // this will return true;
3030
}
3131

3232
public boolean removeAdjacentVertex(E to) {
3333
// use indexes here so it is possible to
3434
// remove easily without implementing
3535
// equals method that ArrayList.remove(Object o) uses
36-
for (int i = 0; i < adjacentVerticies.size(); i++) {
37-
if (adjacentVerticies.get(i).data.compareTo(to) == 0) {
38-
adjacentVerticies.remove(i);
36+
for (int i = 0; i < adjacentVertices.size(); i++) {
37+
if (adjacentVertices.get(i).data.compareTo(to) == 0) {
38+
adjacentVertices.remove(i);
3939
return true;
4040
}
4141
}
@@ -45,7 +45,7 @@ public boolean removeAdjacentVertex(E to) {
4545

4646
/**
4747
* this method removes an edge from the graph between two specified
48-
* verticies
48+
* vertices
4949
*
5050
* @param from the data of the vertex the edge is from
5151
* @param to the data of the vertex the edge is going to
@@ -54,7 +54,7 @@ public boolean removeAdjacentVertex(E to) {
5454
*/
5555
public boolean removeEdge(E from, E to) {
5656
Vertex fromV = null;
57-
for (Vertex v : verticies) {
57+
for (Vertex v : vertices) {
5858
if (from.compareTo(v.data) == 0) {
5959
fromV = v;
6060
break;
@@ -67,7 +67,7 @@ public boolean removeEdge(E from, E to) {
6767
}
6868

6969
/**
70-
* this method adds an edge to the graph between two specified verticies
70+
* this method adds an edge to the graph between two specified vertices
7171
*
7272
* @param from the data of the vertex the edge is from
7373
* @param to the data of the vertex the edge is going to
@@ -76,7 +76,7 @@ public boolean removeEdge(E from, E to) {
7676
*/
7777
public boolean addEdge(E from, E to) {
7878
Vertex fromV = null, toV = null;
79-
for (Vertex v : verticies) {
79+
for (Vertex v : vertices) {
8080
if (from.compareTo(v.data) == 0) { // see if from vertex already exists
8181
fromV = v;
8282
} else if (to.compareTo(v.data) == 0) { // see if to vertex already exists
@@ -88,29 +88,29 @@ public boolean addEdge(E from, E to) {
8888
}
8989
if (fromV == null) {
9090
fromV = new Vertex(from);
91-
verticies.add(fromV);
91+
vertices.add(fromV);
9292
}
9393
if (toV == null) {
9494
toV = new Vertex(to);
95-
verticies.add(toV);
95+
vertices.add(toV);
9696
}
9797
return fromV.addAdjacentVertex(toV);
9898
}
9999

100100
/**
101-
* this gives a list of verticies in the graph and their adjacencies
101+
* this gives a list of vertices in the graph and their adjacencies
102102
*
103103
* @return returns a string describing this graph
104104
*/
105105
@Override
106106
public String toString() {
107107
StringBuilder sb = new StringBuilder();
108-
for (Vertex v : verticies) {
108+
for (Vertex v : vertices) {
109109
sb.append("Vertex: ");
110110
sb.append(v.data);
111111
sb.append("\n");
112-
sb.append("Adjacent verticies: ");
113-
for (Vertex v2 : v.adjacentVerticies) {
112+
sb.append("Adjacent vertices: ");
113+
for (Vertex v2 : v.adjacentVertices) {
114114
sb.append(v2.data);
115115
sb.append(" ");
116116
}

0 commit comments

Comments
 (0)