Mercurial > hg > Members > nobuyasu > Consensus
diff app/models/TPGraph.java @ 74:c5ddd2cc52e1 draft
create copyConsensusTree method.
author | one |
---|---|
date | Thu, 07 Mar 2013 18:40:22 +0900 |
parents | c76b3b60eb18 |
children | 9448734399db |
line wrap: on
line diff
--- a/app/models/TPGraph.java Wed Mar 06 16:57:13 2013 +0900 +++ b/app/models/TPGraph.java Thu Mar 07 18:40:22 2013 +0900 @@ -100,6 +100,11 @@ return setLabel(claim.getVertex(), authorVertex, NodeModel.L_AUTHOR); } + public Edge setLabelPrev(ClaimModel fromClaim, ClaimModel toClaim) { + // fromClaim ---prev---> toClaim + return setLabel(fromClaim.getVertex(), toClaim.getVertex(), NodeModel.L_PREV ); + } + public Boolean setLabelToUsers(ClaimModel claim, String[] users, String label) { for (String userName: users) { Vertex userVertex = graph.getVertex(userName); @@ -175,7 +180,7 @@ iter = set.iterator(); while (iter.hasNext()) { Object childId = iter.next(); - ArrayList<Object> array = getAllUpperVertex(childId); + ArrayList<Object> array = getAllUpperVertexId(childId); for (Object parentId: array) { /* * If there is a number of the number of parent and child in the [set], @@ -197,7 +202,7 @@ /* * Return CLAIM numbers of above [id] CLAIM. */ - public ArrayList<Object> getAllUpperVertex(Object id) { + public ArrayList<Object> getAllUpperVertexId(Object id) { Vertex startV = graph.getVertex(id); ArrayList<Object> vertexArray = new ArrayList<Object>(); while (true) { @@ -214,7 +219,7 @@ return vertexArray; } - public Object getOneUpperVertex(Object id) { + public Object getOneUpperClaimVertexId(Object id) { Vertex startV = graph.getVertex(id); GremlinPipeline<Vertex,Vertex> pipe = new GremlinPipeline<Vertex,Vertex>(); pipe.start(startV).in(NodeModel.L_QUESTION, NodeModel.L_REFUTATION, NodeModel.L_SUGGESTION); @@ -226,6 +231,32 @@ } } + public Object getTopClaimVertexId(Object id) { + Object v = id; + Object upV = id; + while (upV != null) { + v = upV; + upV = getOneUpperClaimVertexId(v); + } + return v; + } + + private void copyDownClaimVertexAndSetLabel(ClaimModel cliam, String label) { + GremlinPipeline<Vertex, Vertex> pipe = new GremlinPipeline<Vertex, Vertex>(); + pipe.start(claim.getVertex()).outE(label); + + } + + public ClaimModel copyConsensusTree(ClaimModel claim) { + ClaimModel topClaim = new ClaimModel(graph.getVertex(getTopClaimVertexId(claim.getId()))); + + + ClaimModel copiedTopClaim = new ClaimModel(graph.addVertex(null)); + + return copiedTopClaim; + } + + public void shutdownGraph() { if (path == null) { return;