-
Notifications
You must be signed in to change notification settings - Fork 0
/
JavaApplication3.java
99 lines (73 loc) · 2.83 KB
/
JavaApplication3.java
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication3;
//import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientEdge;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
//import com.tinkerpop.blueprints.oupls.jung.GraphJung;
//mport edu.uci.ics.jung.algorithms.scoring.PageRank;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
*
* @author User
*/
public class JavaApplication3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
OrientGraph graph = new OrientGraph("remote:localhost/final_2");
//ShortestPath path=new ShortestPath();
//Vertex[] vers = new Vertex[1393382];
System.out.println(" enter 1 for DFS or enter 2 for BFS");
System.out.println("");
Scanner in = new Scanner(System.in);
int choice = in.nextInt();
if(choice == 1)
{
int[][] edge_matrix = new int[12000][12000];
System.out.println(edge_matrix[3][3]);
int i = 0;
//Edge[] edges = new Edge[4000000];
for(Edge e: graph.getEdges())
{
Vertex v1,v2;
v1 = e.getVertex(Direction.IN);
v2 = e.getVertex(Direction.OUT);
if((int)v1.getProperty("node") < 10000 &&(int) v2.getProperty("node") < 10000)
{
edge_matrix[v1.getProperty("node")][v2.getProperty("node")] = 1;
}
//edges[i] = e;
System.out.println(e.getId());
}
DFS dfs = new DFS();
dfs.dfs(edge_matrix, 1); //(graph, source)
}
else if( choice == 2)
{
Graph_bfs g = new Graph_bfs(12000);
for(Edge e: graph.getEdges())
{
Vertex v1,v2;
v1 = e.getVertex(Direction.IN);
v2 = e.getVertex(Direction.OUT);
g.addEdge((int)v1.getProperty("node"), (int)v2.getProperty("node"));
//[v1.getProperty("node")][v2.getProperty("node")]
System.out.println(e.getId());
}
g.BFS(0); // (source node)
}
graph.shutdown();
}
}