Package primitives.graph

Examples of primitives.graph.Graph


  public double evaluate(ClusterHead result) {
    Stack<ClusterNode> toVisit = new Stack<ClusterNode>();
    toVisit.push(result);
    double ret = 0;
   
    Graph g = new Graph();
    for(Node n : result.getNodes()){
      g.addNode(n);
    }
   
    while(!toVisit.isEmpty()){
      ClusterNode current = toVisit.pop();
      ret += calculateComplexity(current, g,  result);
View Full Code Here


  @Before
  public void setUp() throws Exception {
    c = new ClusterNode();
    a = new Node("a");
    b = new Node("b");
    g = new Graph();
    g.addNode(a);
    g.addNode(b);
    outsideIn = new Node("outside -> in ");
    outsideOut = new Node("cluster -> outside");
    c.addNode(a);
View Full Code Here

  Graph g;
  Node a,b,c,d,e,f;
  List<VecInstruction> program;
  @Before
  public void setUp() throws Exception {
    g = new Graph();
    a = new Node("a");
    b = new Node("b");
    c = new Node("c");
    d = new Node("d");
    e = new Node("e");
View Full Code Here

  ClusterHead ch;

  @Before
  public void setup() {
    g = new Graph();
    a = new Node("a");
    b = new Node("b");
    c = new Node("c");
    d = new Node("d");
    e = new Node("e");
View Full Code Here

    assertEquals(ooph.size(),master.getNodes().size());
    assertSame(ooph,master.getNodes());
    master.setNodes(oldOnes);
    assertFalse(ooph == master.getNodes());
    assertSame(oldOnes,master.getNodes());
    Graph someOtherGraph = new Graph();
    Node a, b;
    a = new Node("a");
    b = new Node("b");
    someOtherGraph.addNode(a);
    someOtherGraph.addNode(b);
    someOtherGraph.connect(a, b, "test");
   
    assertTrue(someOtherGraph.connectivity(a, b));
    assertTrue(a.pathTo(b));
    Set<Node> newOnes = someOtherGraph.getNodes();
   
    master.setNodes(newOnes);
   
    assertFalse(master.getNodes().contains(in));
   
View Full Code Here

   
  Graph g;
  List<Node> nodes;
    @Before
    public void setUp() {
        g = new Graph();
    //make a strongly connected graph
   
    nodes = new ArrayList<Node>();
   
   
View Full Code Here

  public void setUp() {

    a = new Node();
    b = new Node();

    g = new Graph();

    g.addNode(a);
    g.addNode(b);

    n = new ClusterHead(g);
View Full Code Here

  Graph g;
  Node a,b,c,d,e,f;
  List<VecInstruction> program;
  @Before
  public void setUp() throws Exception {
    g = new Graph();
    a = new Node("a");
    b = new Node("b");
    c = new Node("c");
    d = new Node("d");
    e = new Node("e");
View Full Code Here


            Logger.getLogger(ExperimentRunner.class.getName()).log(Level.FINE, String.format("Starting clustering of file: %s [%d nodes, %d edges]"
                    , td.getInputname().getName()
                    ,toCluster.getSize()
                    ,new Graph(toCluster.getNodes()).countTransitions()
                    ));
           
            Search gs = null;         
            if(td.getSearchType().equals("GA")){
                gs = new GeneticAlgorithmSearch();
View Full Code Here

  static Pattern transitionLine = Pattern.compile("\\W*\"?" + "([^\"]+)"
      + "\"?" + "\\W*" + "->" + "\\W*" + "\"?" + "([^\"]+)" + "\"?"
      + "\\W*" + "(\\[" + "(.*)" + "\\])?");

        public static ClusterHead loadTreeFromDot(File input) throws IOException{
            Graph g = new Graph();
            BufferedReader in = new BufferedReader(new FileReader(input));
            String line;
    HashMap<String, Node> nodes = new HashMap<String, Node>();

    while ((line = in.readLine()) != null) {
      if (line.matches("^\\W*#.*$"))
                            continue;
      Matcher m = definitionLine.matcher(line);
      if (m.matches()) {
        Matcher m2 = transitionLine.matcher(line);
        if (m2.matches()) {
          String s1 = m2.group(1);
          String s2 = m2.group(2);
          // String s3 = m2.group(3);
          nodes.put(s1, new Node(s1));
          nodes.put(s2, new Node(s2));
        } else {
          String s1 = m.group(1);
          nodes.put(s1, new Node(s1));
        }
      }
    }

    for (String k : nodes.keySet()) {
      g.addNode(nodes.get(k));
    }

    in = new BufferedReader(new FileReader(input));

    while ((line = in.readLine()) != null) {
View Full Code Here

TOP

Related Classes of primitives.graph.Graph

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.