Package cu.repsystestbed.graphs

Examples of cu.repsystestbed.graphs.TrustGraph


      return new ReputationGraph(new ReputationEdgeFactory());
     
    }
    else if(graphType.equalsIgnoreCase(TRUSTGRAPH))
    {
      return new TrustGraph(new TrustEdgeFactory());
    }
    else
    {
      throw new WorkflowParserException("Unknown graph type.");
    }
View Full Code Here


{
  static private Logger logger = Logger.getLogger(TrustGraphCreator.class);
 
  public static TrustGraph createGraph(String arffFileName) throws Exception
  {
    TrustGraph trustGraph = new TrustGraph(new TrustEdgeFactory());
   
    Util.assertNotNull(arffFileName);
    Util.assertFileExists(arffFileName);
   
    DataSource source;
    try
    {
      source = new DataSource(arffFileName);
      Instances instances = source.getDataSet();
      logger.debug("Number of instances in arff file is " + instances.numInstances());
     
      Enumeration enu = instances.enumerateInstances();
      //get all the feedback lines
     
      while(enu.hasMoreElements())
      {
        Instance temp = (Instance)enu.nextElement();
        logger.info("Parsing " + temp);
        String[] feedbackInstance = new String[3];
        //go through each feedback line
       
        if(temp.numValues()!=2) throw new GenericTestbedException("Trust line does not have 2 elements. This is illegal.");
       
        for(int i=0;i<temp.numValues();i++)
        {
          //number of values == 2
          feedbackInstance[i] = temp.stringValue(i);         
        }
        Agent src = new Agent(new Integer(feedbackInstance[0]));
        Agent sink = new Agent(new Integer(feedbackInstance[1]));
       
        if(!trustGraph.containsVertex(src))
        {
          trustGraph.addVertex(src);
        }
       
        if(!trustGraph.containsVertex(sink))
        {
          trustGraph.addVertex(sink);
        }
       
        trustGraph.addEdge(src, sink);
       
      }

    } catch (Exception e)
    {
View Full Code Here

TOP

Related Classes of cu.repsystestbed.graphs.TrustGraph

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.