在JUNG图中表示猫头鹰数据并使用先前

时间:2015-08-30 13:21:27

标签: graph ontology jung

我正在将猫头鹰数据加载到JUNG图中,以便使用先前算法计算PageRank。

我为本体创建了一个JUNG图

        // vertices: RDFNodes, edges: Statements
        //Graph<RDFNode, Statement> g = new JenaJungGraph(model);

        DirectedGraph<RDFNode,Statement> g = new DirectedSparseGraph<RDFNode,Statement>();

        String resource = "C:\\Users\\Desktop\\camera.owl";
        Model m = FileManager.get().loadModel(resource);
        m.write(System.out);

          StmtIterator iter = m.listStatements();

            // print out the predicate, subject and object of each statement
            while (iter.hasNext()) {
                Statement stmt      = iter.nextStatement();         // get next statement
                RDFNode subject   = stmt.getSubject();   // get the subject
                RDFNode object    = stmt.getObject();    // get the object

                g.addVertex( subject);

               if(object instanceof Resource || !object.isLiteral())
               {

                g.addVertex( object );
                g.addEdge( stmt, subject, object, EdgeType.DIRECTED);  

            }
            }

                Collection<RDFNode> collectionOfVertices = g.getVertices();

                System.out.println("number of vertices:" + collectionOfVertices.size());
                System.out.println("number of edges:" +g.getEdgeCount());

 }

}

现在我想为此图计算PageRank和Prior。如何计算这一个?任何提示?

0 个答案:

没有答案