Search in sources :

Example 1 with LearningGraphBuilder

use of edu.cmu.ml.proppr.graph.LearningGraphBuilder in project ProPPR by TeamCohen.

the class RedBlueGraph method setup.

@Before
public void setup() {
    //		if (!Logger.getRootLogger().getAllAppenders().hasMoreElements()) {
    //			BasicConfigurator.configure(); Logger.getRootLogger().setLevel(Level.WARN);
    //		}
    LearningGraphBuilder lgb = new ArrayLearningGraphBuilder();
    brGraph = (LearningGraph) lgb.create(new SimpleSymbolTable<String>());
    lgb.index(1);
    lgb.setGraphSize(brGraph, magicNumber * 2, -1, -1);
    //		brSRWs = new ArrayList<SRW>();
    //		Collections.addAll(brSRWs, new L2SqLossSRW(), new L2SqLossSRW(), new L2SqLossSRW());
    {
        int u = nodes.getId("b0"), v = nodes.getId("r0");
        HashMap<String, Double> ff = new HashMap<String, Double>();
        ff.put("fromb", 1.0);
        ff.put("tor", 1.0);
        lgb.addOutlink(brGraph, u, makeOutlink(lgb, ff, v));
        ff = new HashMap<String, Double>();
        ff.put("fromr", 1.0);
        ff.put("tob", 1.0);
        lgb.addOutlink(brGraph, v, makeOutlink(lgb, ff, u));
    }
    addColor(lgb, brGraph, magicNumber, "r");
    addColor(lgb, brGraph, magicNumber, "b");
    // save sets of red and blue nodes
    reds = new TreeSet<String>();
    blues = new TreeSet<String>();
    for (int ui = 1; ui < (2 * magicNumber + 1); ui++) {
        String u = nodes.getSymbol(ui);
        if (u.startsWith("b"))
            blues.add(u);
        else
            reds.add(u);
    }
    moreSetup(lgb);
    lgb.freeze(brGraph);
//			System.err.println("\n"+brGraphs.get(0).dump("r0"));
}
Also used : HashMap(java.util.HashMap) TObjectDoubleHashMap(gnu.trove.map.hash.TObjectDoubleHashMap) TIntDoubleHashMap(gnu.trove.map.hash.TIntDoubleHashMap) ArrayLearningGraphBuilder(edu.cmu.ml.proppr.graph.ArrayLearningGraphBuilder) LearningGraphBuilder(edu.cmu.ml.proppr.graph.LearningGraphBuilder) ArrayLearningGraphBuilder(edu.cmu.ml.proppr.graph.ArrayLearningGraphBuilder) Before(org.junit.Before)

Aggregations

ArrayLearningGraphBuilder (edu.cmu.ml.proppr.graph.ArrayLearningGraphBuilder)1 LearningGraphBuilder (edu.cmu.ml.proppr.graph.LearningGraphBuilder)1 TIntDoubleHashMap (gnu.trove.map.hash.TIntDoubleHashMap)1 TObjectDoubleHashMap (gnu.trove.map.hash.TObjectDoubleHashMap)1 HashMap (java.util.HashMap)1 Before (org.junit.Before)1