-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRemoveVertices.java
More file actions
41 lines (36 loc) · 929 Bytes
/
RemoveVertices.java
File metadata and controls
41 lines (36 loc) · 929 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package datastructure.graph;
import java.util.LinkedList;
/**
* The type Remove vertices.
*/
public class RemoveVertices {
/**
* Remove.
*
* @param graph the graph
* @param source the source
* @param destination the destination
*/
public static void remove(AdjacencyListGraph graph,int source,int destination){
LinkedList<Integer> list = graph.adjacencyList[source];
list.removeFirstOccurrence(destination);
}
/**
* Main.
*
* @param args the args
*/
public static void main(String args[]) {
AdjacencyListGraph g=new AdjacencyListGraph(5);
g.addEdge(0,1);
g.addEdge(0,2);
g.addEdge(1,3);
g.addEdge(3,4);
g.addEdge(1,4);
System.out.println("Before:");
g.printGraph();
remove(g, 1, 3);
System.out.println("After:");
g.printGraph();
}
}