Mercurial > hg > Members > nobuyasu > TPPageRank
comparison src/pagerank/LinkConvertGraph.java @ 5:140272228818 draft
fix LinkToVertex.java
author | one |
---|---|
date | Wed, 05 Sep 2012 15:38:57 +0900 |
parents | dcd59917a2dd |
children | c7b139ff27e2 |
comparison
equal
deleted
inserted
replaced
4:dcd59917a2dd | 5:140272228818 |
---|---|
88 | 88 |
89 | 89 |
90 | 90 |
91 | 91 |
92 public static void main(String[] args) { | 92 public static void main(String[] args) { |
93 // final String filename = "./resources/article.xml"; | 93 final String filename = "./resources/article.xml"; |
94 final String filename = "/Users/aotokage/testProgram/wiki/ja-pages_current.xml"; | 94 // final String filename = "/Users/aotokage/testProgram/wiki/ja-pages_current.xml"; |
95 | 95 |
96 LinkConvertGraph lcg; | 96 LinkConvertGraph lcg; |
97 | 97 |
98 try { | 98 try { |
99 | 99 |
110 | 110 |
111 final String fileDB = "./resources/tinkerpopDB"; | 111 final String fileDB = "./resources/tinkerpopDB"; |
112 | 112 |
113 Graph graph = new TinkerGraph(); | 113 Graph graph = new TinkerGraph(); |
114 FileOutputStream out = new FileOutputStream(new File(fileDB)); | 114 FileOutputStream out = new FileOutputStream(new File(fileDB)); |
115 LinkToVertex ltn = new LinkToVertex(graph); | 115 LinkToVertex ltv = new LinkToVertex(graph); |
116 | 116 |
117 long countId = 1; | |
117 for (Map.Entry<String, HashSet<String>> map : hash.entrySet()) { | 118 for (Map.Entry<String, HashSet<String>> map : hash.entrySet()) { |
118 String pageTitle = map.getKey(); | 119 String pageTitle = map.getKey(); |
119 | 120 |
120 Vertex v;// = graph.addVertex(null); | 121 Vertex v;// = graph.addVertex(null); |
121 | 122 |
122 if ( ltn.getId(pageTitle) == null ) { | 123 if ( ltv.getId(pageTitle) == null ) { |
123 v = ltn.createVertexWithPageTitle(pageTitle); | 124 v = ltv.createVertexWithPageTitle(pageTitle,countId); |
124 | 125 ltv.setPageRank(v, (Double)0.0); |
126 countId++; | |
125 } else { | 127 } else { |
126 v = ltn.getVertex(pageTitle); | 128 v = ltv.getVertex(pageTitle); |
127 } | 129 } |
128 | 130 |
129 for (String linkPageTitle : map.getValue()) { | 131 for (String linkPageTitle : map.getValue()) { |
130 Vertex linkV; | 132 Vertex linkV; |
131 if ( ltn.getId(linkPageTitle) == null) { | 133 if ( ltv.getId(linkPageTitle) == null) { |
132 linkV = ltn.createVertexWithPageTitle(linkPageTitle); | 134 linkV = ltv.createVertexWithPageTitle(linkPageTitle,countId); |
133 ltn.setPageRank(linkV, (Double)0.0); | 135 countId++; |
136 ltv.setPageRank(linkV, (Double)0.0); | |
134 } else { | 137 } else { |
135 linkV = ltn.getVertex(linkPageTitle); | 138 linkV = ltv.getVertex(linkPageTitle); |
136 } | 139 } |
137 ltn.setHasLink(v, linkV); | 140 ltv.setHasLink(v, linkV); |
138 } | 141 } |
139 | 142 |
140 } | 143 } |
141 | 144 |
142 GraphMLWriter.outputGraph(graph, out); | 145 GraphMLWriter.outputGraph(graph, out); |