Merge branch 'master' into master

This commit is contained in:
Loredana Crusoveanu
2019-06-08 14:11:25 +03:00
committed by GitHub
508 changed files with 16341 additions and 2717 deletions

View File

@@ -52,3 +52,4 @@
- [Guide to Creating and Running a Jar File in Java](https://www.baeldung.com/java-create-jar)
- [Making a JSON POST Request With HttpURLConnection](https://www.baeldung.com/httpurlconnection-post)
- [How to Find an Exceptions Root Cause in Java](https://www.baeldung.com/java-exception-root-cause)
- [Convert Hex to ASCII in Java](https://www.baeldung.com/java-convert-hex-to-ascii)

View File

@@ -1 +0,0 @@
### Relevant Articles:

View File

@@ -19,7 +19,7 @@ public class Graph {
void removeVertex(String label) {
Vertex v = new Vertex(label);
adjVertices.values().stream().map(e -> e.remove(v)).collect(Collectors.toList());
adjVertices.values().stream().forEach(e -> e.remove(v));
adjVertices.remove(new Vertex(label));
}

View File

@@ -1,20 +1,31 @@
package com.baeldung.graph;
import org.junit.Assert;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class GraphTraversalUnitTest {
public class GraphUnitTest {
@Test
public void givenAGraph_whenTraversingDepthFirst_thenExpectedResult() {
Graph graph = createGraph();
Assert.assertEquals("[Bob, Rob, Maria, Alice, Mark]",
assertEquals("[Bob, Rob, Maria, Alice, Mark]",
GraphTraversal.depthFirstTraversal(graph, "Bob").toString());
}
@Test
public void givenAGraph_whenTraversingBreadthFirst_thenExpectedResult() {
Graph graph = createGraph();
Assert.assertEquals("[Bob, Alice, Rob, Mark, Maria]",
assertEquals("[Bob, Alice, Rob, Mark, Maria]",
GraphTraversal.breadthFirstTraversal(graph, "Bob").toString());
}
@Test
public void givenAGraph_whenRemoveVertex_thenVertedNotFound() {
Graph graph = createGraph();
assertEquals("[Bob, Alice, Rob, Mark, Maria]",
GraphTraversal.breadthFirstTraversal(graph, "Bob").toString());
graph.removeVertex("Maria");
assertEquals("[Bob, Alice, Rob, Mark]",
GraphTraversal.breadthFirstTraversal(graph, "Bob").toString());
}