View difference between Paste ID: af4Nb1Nb and VyqtUTZ2
SHOW: | | - or go back to the newest paste.
1
package my.annotation;
2
3
import java.util.*;
4-
import org.apache.commons.logging.impl.SimpleLog;
4+
5
import org.graphstream.graph.implementations.*;
6
import org.graphstream.graph.implementations.*;
7
8
public class TestGraph {
9
10
	/**
11
	 * @param args
12
	 * @throws Exception 
13
	 */
14
	public static Graph createRandomGraph(){
15
		Graph g = new SingleGraph("A");
16
		Node n;
17
		Integer j;
18
		for (int i=0;i<10;i++){
19
			j = new Integer(i);
20
			n= g.addNode(j.toString());
21
			n.addAttribute("ui.label", j);
22
		}
23
		Edge e;
24
		int c=0;
25
		for (int i=1;i<10;i++){
26
			j = new Integer(i);
27
			e = g.addEdge(""+c++,"0",j.toString());
28
		}
29
		return g;
30
	}
31
	public static Graph processGraph(List<String> l,Graph g){
32
		int c=0;
33
		System.out.println("Node count "+g.getNodeCount());
34
		for(Node n: g){
35-
		for(Node n: g.getEachNode()){
35+
36
				g.removeNode(n.getId());
37
			}
38
		c++;
39
		}
40
		System.out.println("Iterations performed "+c);
41
		return g;
42
	}
43
	public static void main(String[] args) throws Exception {
44
		// TODO Auto-generated method stub
45
		
46
		Graph g = new SingleGraph("A");
47
		g = createRandomGraph();
48
		List<String> l = new ArrayList<String>();
49
		l.add("0");
50
		g = processGraph(l, g);
51
		g.display();
52
	}
53
	
54
	}