Permalink
Browse files

Merge branch 'master' of git.sones:sones-community-edition into Remot…

…eAPI_bug_fix
  • Loading branch information...
2 parents e1eaeac + bae6d88 commit 3f9100c11ba67e27319a797d8e62d1f301c1baaf Markus Zorn committed Nov 22, 2011
View
7 GraphQL/IGraphQL/Result/QueryResult.cs
@@ -106,7 +106,12 @@ public UInt64 NumberOfAffectedVertices
/// <param name="myDuration">The time that was spent on executing the query</param>
/// <param name="myVertices">The vertices that should be available within the query result</param>
/// <param name="myError">The error which occured during execution</param>
- public QueryResult(String myQuery, String myQLName, UInt64 myDuration, ResultType myResultType, IEnumerable<IVertexView> myVertices, ASonesException myError)
+ public QueryResult(String myQuery,
+ String myQLName,
+ UInt64 myDuration,
+ ResultType myResultType,
+ IEnumerable<IVertexView> myVertices,
+ ASonesException myError)
{
TypeOfResult = myResultType;
Vertices = myVertices ?? new List<IVertexView>();
View
92 ...ins/GraphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/Dijkstra/BufferDijkstra.cs
@@ -1,4 +1,24 @@
-using System;
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -7,87 +27,83 @@
namespace sones.Plugins.SonesGQL.Functions.Dijkstra
{
#region buffer
- public class bufferDijkstra
- {
- SortedDictionary<Tuple<double, long>, Tuple<IVertex, double, ulong>> buffer;
+ public class BufferDijkstra
+ {
+ private SortedDictionary<Tuple<double, long>, Tuple<IVertex, double, ulong>> _buffer;
+ private int _count;
- public int Count { get { return count; } }
- int count;
+ public int Count { get { return _count; } }
+
- public bufferDijkstra()
+ public BufferDijkstra()
{
- buffer = new SortedDictionary<Tuple<double, long>, Tuple<IVertex, double, ulong>>();
-
- count = 0;
-
+ _buffer = new SortedDictionary<Tuple<double, long>, Tuple<IVertex, double, ulong>>();
+ _count = 0;
}
- public void add(IVertex current_node, double current_distance, UInt64 current_depth)
+ public void Add(IVertex current_node, double current_distance, UInt64 current_depth)
{
var id = current_node.VertexID;
- buffer.Add(Tuple.Create(current_distance, id), Tuple.Create(current_node, current_distance, current_depth));
-
- count++;
-
+ _buffer.Add(Tuple.Create(current_distance, id), Tuple.Create(current_node, current_distance, current_depth));
+ _count++;
}
- public Tuple<IVertex, double, ulong> min()
+
+ public Tuple<IVertex, double, ulong> Min()
{
- return buffer.ElementAt(0).Value;
+ return _buffer.ElementAt(0).Value;
}
- public void remove(double key_primary, long key_secondary)
+ public void Remove(double key_primary, long key_secondary)
{
- buffer.Remove(Tuple.Create(key_primary, key_secondary));
- count--;
+ _buffer.Remove(Tuple.Create(key_primary, key_secondary));
+ _count--;
}
- public void set(double key_primary, IVertex value, double current_distance, ulong current_depth)
+ public void Set(double key_primary, IVertex value, double current_distance, ulong current_depth)
{
var key = value.VertexID;
- buffer.Remove(Tuple.Create(key_primary, key));
- buffer.Add(Tuple.Create(current_distance, key), Tuple.Create(value, current_distance, current_depth));
+ _buffer.Remove(Tuple.Create(key_primary, key));
+ _buffer.Add(Tuple.Create(current_distance, key), Tuple.Create(value, current_distance, current_depth));
}
- public ulong getDepth(double key_primary, long current_vertex)
+ public ulong GetDepth(double key_primary, long current_vertex)
{
- return buffer[Tuple.Create(key_primary, current_vertex)].Item3;
+ return _buffer[Tuple.Create(key_primary, current_vertex)].Item3;
}
- public ulong getDepth(int current_vertexID)
+ public ulong GetDepth(int current_vertexID)
{
- return buffer.ElementAt(current_vertexID).Value.Item3;
+ return _buffer.ElementAt(current_vertexID).Value.Item3;
}
- public double getDistance(double key_primary, long current_vertex)
+ public double GetDistance(double key_primary, long current_vertex)
{
- return buffer[Tuple.Create(key_primary, current_vertex)].Item2;
+ return _buffer[Tuple.Create(key_primary, current_vertex)].Item2;
}
- public double getDistance(int current_vertexID)
+ public double GetDistance(int current_vertexID)
{
- return buffer.ElementAt(current_vertexID).Value.Item2;
+ return _buffer.ElementAt(current_vertexID).Value.Item2;
}
- public Tuple<IVertex, double, ulong> getElement(double key_primary, long index)
+ public Tuple<IVertex, double, ulong> GetElement(double key_primary, long index)
{
Tuple<IVertex, double, ulong> output;
- buffer.TryGetValue(Tuple.Create(key_primary, index), out output);
+ _buffer.TryGetValue(Tuple.Create(key_primary, index), out output);
return output;
}
public void Clear()
{
- buffer.Clear();
- count = 0;
+ _buffer.Clear();
+ _count = 0;
}
-
-
}
#endregion
}
View
117 Plugins/GraphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/Dijkstra/DataDijkstra.cs
@@ -0,0 +1,117 @@
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using sones.Library.PropertyHyperGraph;
+using sones.GraphDB.TypeSystem;
+
+namespace sones.Plugins.SonesGQL.Functions.Dijkstra
+{
+ #region DataDijkstra
+
+ public class DataDijkstra
+ {
+
+ private Dictionary<long, Tuple<IVertex, double, ulong, Tuple<ISingleEdge,IOutgoingEdgeDefinition>, IVertex>> _list;
+ private int _count;
+
+ public int Count { get { return Count; } }
+
+
+ public DataDijkstra()
+ {
+ _list = new Dictionary<long, Tuple<IVertex, double, ulong, Tuple<ISingleEdge, IOutgoingEdgeDefinition>, IVertex>>();
+ _count = 0;
+
+ }
+
+ public void Add(IVertex current_node, double current_distance, UInt64 current_depth, ISingleEdge current_edge,IOutgoingEdgeDefinition edgeType, IVertex father)
+ {
+ var id = current_node.VertexID;
+ _list.Add(id, Tuple.Create(current_node, current_distance, current_depth, Tuple.Create(current_edge,edgeType), father));
+ _count++;
+ }
+
+
+ public void Set(IVertex value, double current_distance, ulong current_depth, ISingleEdge current_edge,IOutgoingEdgeDefinition edgeType, IVertex father)
+ {
+ var key = value.VertexID;
+ _list[key] = Tuple.Create(value, current_distance, current_depth, Tuple.Create(current_edge,edgeType), father);
+
+ }
+
+ public ulong GetDepth(long current_vertex)
+ {
+
+ return _list[current_vertex].Item3;
+ }
+
+ public ulong GetDepth(int current_vertexID)
+ {
+
+ return _list.ElementAt(current_vertexID).Value.Item3;
+ }
+
+ public double GetDistance(long current_vertex)
+ {
+
+ return _list[current_vertex].Item2;
+ }
+
+ public double GetDistance(int current_vertexID)
+ {
+
+ return _list.ElementAt(current_vertexID).Value.Item2;
+ }
+
+ public Tuple<IVertex, double, ulong, Tuple<ISingleEdge,IOutgoingEdgeDefinition>, IVertex> GetElement(long key)
+ {
+ Tuple<IVertex, double, ulong, Tuple<ISingleEdge,IOutgoingEdgeDefinition>, IVertex> temp;
+ _list.TryGetValue(key, out temp);
+ return temp;
+ }
+
+ private Tuple<IVertex, double, ulong, Tuple<ISingleEdge, IOutgoingEdgeDefinition>, IVertex> GetTuple(int key)
+ {
+ return this._list.ElementAt(key).Value;
+ }
+
+ private Tuple<IVertex, double, ulong, Tuple<ISingleEdge, IOutgoingEdgeDefinition>, IVertex> GetTuple(long key)
+ {
+ return this._list[key];
+ }
+
+ public void Clear()
+ {
+ _list.Clear();
+ _count = 0;
+ }
+
+ private bool ConstainsKey(long key)
+ {
+ return this._list.ContainsKey(key);
+ }
+ }
+
+ #endregion
+}
View
114 Plugins/GraphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/Dijkstra/Dijkstra.cs
@@ -1,4 +1,24 @@
-using System;
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -29,11 +49,13 @@ public Dijkstra()
Parameters.Add(new ParameterValue("EdgeType",typeof(string)));
}
+
#endregion
+
#region show all edges with target vertex 'vertexType' for 'vertexType'
- private Dictionary<IOutgoingEdgeDefinition,Tuple<bool, long>> allEdgeWithTargetVertex(IVertexType vertexType)
+ private Dictionary<IOutgoingEdgeDefinition,Tuple<bool, long>> AllEdgeWithTargetVertex(IVertexType vertexType)
{
Dictionary<IOutgoingEdgeDefinition, Tuple<bool, long>> idList = new Dictionary<IOutgoingEdgeDefinition, Tuple<bool, long>>();
var temp = vertexType.GetOutgoingEdgeDefinitions(true);
@@ -56,7 +78,9 @@ public Dijkstra()
}
return idList;
}
+
#endregion
+
#region Parser from String to IOutgoingEdgeDefinition and check property edgeType.InnerEdgeType.HasProperty("Weight")
private Dictionary<IOutgoingEdgeDefinition, Tuple<bool, long>> StringParser(String current_string,
@@ -112,6 +136,7 @@ public Dijkstra()
return idList;
}
#endregion
+
#region ValidateWorkingBase
public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken)
@@ -135,7 +160,9 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
}
}
#endregion
+
#region ExecFunc
+
public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition,
Object myCallingObject,
IVertex myStartVertex,
@@ -205,7 +232,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
{
if (edgeType.Contains("all edgeType"))
{
- edgeTypeID = this.allEdgeWithTargetVertex(myType);
+ edgeTypeID = this.AllEdgeWithTargetVertex(myType);
}
else
{
@@ -229,13 +256,13 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- bufferDijkstra buf = new bufferDijkstra();
- dataDijkstra lists = new dataDijkstra();
+ BufferDijkstra buf = new BufferDijkstra();
+ DataDijkstra lists = new DataDijkstra();
- buf.add(myStartVertex, 0, 0);
- lists.add(currentVertex, 0, 0, null,null, currentVertex);
+ buf.Add(myStartVertex, 0, 0);
+ lists.Add(currentVertex, 0, 0, null,null, currentVertex);
@@ -306,7 +333,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
var current_singleEdge = AllsingleEdge.ElementAt(iCount).Item1;
- var TargetVertexID = lists.getElement(TargetVertex.VertexID);
+ var TargetVertexID = lists.GetElement(TargetVertex.VertexID);
if (TargetVertexID == null)
{
@@ -316,13 +343,13 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- buf.add(TargetVertex,
+ buf.Add(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertex,
+ lists.Add(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -338,12 +365,12 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- buf.add(TargetVertex,
+ buf.Add(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertex,
+ lists.Add(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -363,11 +390,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- buf.set(TargetVertexID.Item2,TargetVertex,
+ buf.Set(TargetVertexID.Item2,TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertex,
+ lists.Set(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -385,11 +412,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
endvertexDepth > currentVertexDepth + 1))
{
- buf.set(TargetVertexID.Item2,TargetVertex,
+ buf.Set(TargetVertexID.Item2,TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertex,
+ lists.Set(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -405,11 +432,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- buf.set(TargetVertexID.Item2,TargetVertex,
+ buf.Set(TargetVertexID.Item2,TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertex,
+ lists.Set(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -427,11 +454,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- buf.set(TargetVertexID.Item2,TargetVertex,
+ buf.Set(TargetVertexID.Item2,TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertex,
+ lists.Set(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -448,7 +475,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
endVertexFlag = true;
- var endNode = lists.getElement(endVertex.VertexID);
+ var endNode = lists.GetElement(endVertex.VertexID);
endVertexDistance = endNode.Item2;
endvertexDepth = endNode.Item3;
@@ -470,15 +497,15 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
else
{
- buf.remove(currentVertexDistance,currentVertex.VertexID);
+ buf.Remove(currentVertexDistance,currentVertex.VertexID);
}
//Minimum distance from Buffer
if (buf.Count != 0)
{
- var minVertex = buf.min();
+ var minVertex = buf.Min();
currentVertex = minVertex.Item1;
currentVertexDistance = minVertex.Item2;
currentVertexDepth = minVertex.Item3;
@@ -497,7 +524,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
while (currentVertex != myStartVertex)
{
- var current_tuple = lists.getElement(currentVertex.VertexID);
+ var current_tuple = lists.GetElement(currentVertex.VertexID);
if (current_tuple == null)
throw new InvalidFunctionParameterException("MaxDepth", "Max depth to low or end node is not with start node connected, find't end node", maxDepth);
@@ -519,7 +546,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
- var path = createVertexView(myPropertyID, VertexBuffer, distanceBuffer, edgeBuffer, depthBuffer);
+ var path = CreateVertexView(myPropertyID, VertexBuffer, distanceBuffer, edgeBuffer, depthBuffer);
#endregion
@@ -552,7 +579,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
/// <param name="mySecurityToken"></param>
/// <param name="myTransactionToken"></param>
/// <returns></returns>
- private Tuple<IVertex, dataDijkstra> findShortPathToAll(IAttributeDefinition myAttributeDefinition,
+ private Tuple<IVertex, DataDijkstra> FindShortPathToAll(IAttributeDefinition myAttributeDefinition,
Object myCallingObject,
IVertex myStartVertex,
IGraphDB myGraphDB,
@@ -586,12 +613,12 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
var edgeTypeDifinition = myType.GetOutgoingEdgeDefinition(myAttributeDefinition.Name);
- dataDijkstra lists = new dataDijkstra();
- bufferDijkstra buffer = new bufferDijkstra();
+ DataDijkstra lists = new DataDijkstra();
+ BufferDijkstra buffer = new BufferDijkstra();
- buffer.add(myStartVertex, 0, 0);
- lists.add(currentVertex, 0, 0, null,null, currentVertex);
+ buffer.Add(myStartVertex, 0, 0);
+ lists.Add(currentVertex, 0, 0, null,null, currentVertex);
double currentVertexDistance = 0;
@@ -630,18 +657,18 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
var current_singleEdge = singleEdge.ElementAt(iCount);
- var TargetVertexID = lists.getElement(TargetVertex.VertexID);
+ var TargetVertexID = lists.GetElement(TargetVertex.VertexID);
if (TargetVertexID == null)
{
- buffer.add(TargetVertex,
+ buffer.Add(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertex,
+ lists.Add(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -654,11 +681,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
{
- buffer.set(TargetVertexID.Item2,TargetVertex,
+ buffer.Set(TargetVertexID.Item2,TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertex,
+ lists.Set(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -674,11 +701,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
{
- buffer.set(TargetVertexID.Item2,TargetVertex,
+ buffer.Set(TargetVertexID.Item2,TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertex,
+ lists.Set(TargetVertex,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_singleEdge,
@@ -696,15 +723,15 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
}
}
- buffer.remove(currentVertexDistance,currentVertex.VertexID);
+ buffer.Remove(currentVertexDistance,currentVertex.VertexID);
//Minimum in distance from Buffer
if (buffer.Count != 0)
{
- var minVertex = buffer.min();
+ var minVertex = buffer.Min();
currentVertex = minVertex.Item1;
currentVertexDistance = minVertex.Item2;
currentVertexDepth = minVertex.Item3;
@@ -725,11 +752,11 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
return result;
}
- #endregion
-
+ #endregion
#region create Vertex View
- private VertexView createVertexView(long myPropertyID, List<IVertex> current_vertices,
+
+ private VertexView CreateVertexView(long myPropertyID, List<IVertex> current_vertices,
List<double> current_distance, List<Tuple<ISingleEdge, IOutgoingEdgeDefinition>> edge, List<UInt64> current_depth)
{
@@ -778,7 +805,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
if (current_vertices.Count != 0)
{
- singleEdges.Add(new SingleEdgeView(myPropertyTwo, createVertexView(myPropertyID, current_vertices, current_distance,
+ singleEdges.Add(new SingleEdgeView(myPropertyTwo, CreateVertexView(myPropertyID, current_vertices, current_distance,
edge, current_depth)));
}
@@ -799,6 +826,7 @@ public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphD
#endregion
#region IPluginable member
+
public override PluginParameters<Type> SetableParameters
{
get { return new PluginParameters<Type>(); }
View
2 Plugins/GraphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/Dijkstra/Dijkstra.csproj
@@ -41,7 +41,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BufferDijkstra.cs" />
- <Compile Include="dataDijkstra.cs" />
+ <Compile Include="DataDijkstra.cs" />
<Compile Include="Dijkstra.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
View
96 Plugins/GraphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/Dijkstra/dataDijkstra.cs
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using sones.Library.PropertyHyperGraph;
-using sones.GraphDB.TypeSystem;
-
-namespace sones.Plugins.SonesGQL.Functions.Dijkstra
-{
- #region dataDijkstra
- public class dataDijkstra
- {
-
- Dictionary<long, Tuple<IVertex, double, ulong, Tuple<ISingleEdge,IOutgoingEdgeDefinition>, IVertex>> list;
- public int Count { get { return Count; } }
-
- int count;
-
- public dataDijkstra()
- {
- list = new Dictionary<long, Tuple<IVertex, double, ulong, Tuple<ISingleEdge, IOutgoingEdgeDefinition>, IVertex>>();
- count = 0;
-
- }
- public void add(IVertex current_node, double current_distance, UInt64 current_depth, ISingleEdge current_edge,IOutgoingEdgeDefinition edgeType, IVertex father)
- {
- var id = current_node.VertexID;
- list.Add(id, Tuple.Create(current_node, current_distance, current_depth, Tuple.Create(current_edge,edgeType), father));
- count++;
- }
-
-
- public void set(IVertex value, double current_distance, ulong current_depth, ISingleEdge current_edge,IOutgoingEdgeDefinition edgeType, IVertex father)
- {
- var key = value.VertexID;
- list[key] = Tuple.Create(value, current_distance, current_depth, Tuple.Create(current_edge,edgeType), father);
-
- }
-
- public ulong getDepth(long current_vertex)
- {
-
- return list[current_vertex].Item3;
- }
-
- public ulong getDepth(int current_vertexID)
- {
-
- return list.ElementAt(current_vertexID).Value.Item3;
- }
-
- public double getDistance(long current_vertex)
- {
-
- return list[current_vertex].Item2;
- }
-
- public double getDistance(int current_vertexID)
- {
-
- return list.ElementAt(current_vertexID).Value.Item2;
- }
-
- public Tuple<IVertex, double, ulong, Tuple<ISingleEdge,IOutgoingEdgeDefinition>, IVertex> getElement(long key)
- {
- Tuple<IVertex, double, ulong, Tuple<ISingleEdge,IOutgoingEdgeDefinition>, IVertex> temp;
- list.TryGetValue(key, out temp);
- return temp;
- }
-
- private Tuple<IVertex, double, ulong, Tuple<ISingleEdge, IOutgoingEdgeDefinition>, IVertex> getTuple(int key)
- {
- return this.list.ElementAt(key).Value;
- }
-
- private Tuple<IVertex, double, ulong, Tuple<ISingleEdge, IOutgoingEdgeDefinition>, IVertex> getTuple(long key)
- {
- return this.list[key];
- }
-
- public void Clear()
- {
- list.Clear();
- count = 0;
- }
-
- private bool ConstainsKey(long key)
- {
-
- return this.list.ContainsKey(key);
- }
-
-
- }
- #endregion
-}
View
108 ...onesGQL/Functions/Implementations/GraphAlgorithms/TypesConnect/BufferForFindPathSchema.cs
@@ -0,0 +1,108 @@
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using sones.GraphDB.TypeSystem;
+
+namespace sones.Plugins.SonesGQL.Functions.TypesConnect
+{
+ #region BufferForFindPathSchema
+
+ public class BufferForFindPathSchema
+ {
+
+ private SortedDictionary<Tuple<double, long>, Tuple<IVertexType, double, ulong>> _buf;
+ private int _count;
+
+ public int Count { get { return _count; } }
+
+ public BufferForFindPathSchema()
+ {
+ _buf = new SortedDictionary<Tuple<double, long>, Tuple<IVertexType, double, ulong>>();
+
+ _count = 0;
+ }
+
+ public void Add(IVertexType current_node, double current_distance, UInt64 current_depth)
+ {
+ var id = current_node.ID;
+ _buf.Add(Tuple.Create(current_distance, id), Tuple.Create(current_node, current_distance, current_depth));
+
+ _count++;
+ }
+
+ public Tuple<IVertexType, double, ulong> Min()
+ {
+ return _buf.ElementAt(0).Value;
+ }
+
+
+ public void Remove(double key_primary, long key_secondary)
+ {
+ _buf.Remove(Tuple.Create(key_primary, key_secondary));
+ _count--;
+ }
+
+ public void Set(double key_primary, IVertexType value, double current_distance, ulong current_depth)
+ {
+ var key = value.ID;
+ _buf.Remove(Tuple.Create(key_primary, key));
+ _buf.Add(Tuple.Create(current_distance, key), Tuple.Create(value, current_distance, current_depth));
+ }
+
+ public ulong GetDepth(double key_primary, long current_vertex)
+ {
+ return _buf[Tuple.Create(key_primary, current_vertex)].Item3;
+ }
+
+ public ulong GetDepth(int current_vertexID)
+ {
+ return _buf.ElementAt(current_vertexID).Value.Item3;
+ }
+
+ public double GetDistance(double key_primary, long current_vertex)
+ {
+ return _buf[Tuple.Create(key_primary, current_vertex)].Item2;
+ }
+
+ public double GetDistance(int current_vertexID)
+ {
+ return _buf.ElementAt(current_vertexID).Value.Item2;
+ }
+
+ public Tuple<IVertexType, double, ulong> GetElement(double key_primary, long index)
+ {
+ Tuple<IVertexType, double, ulong> output;
+ _buf.TryGetValue(Tuple.Create(key_primary, index), out output);
+ return output;
+ }
+
+ public void Clear()
+ {
+ _buf.Clear();
+ _count = 0;
+ }
+
+ }
+ #endregion
+}
View
112 .../SonesGQL/Functions/Implementations/GraphAlgorithms/TypesConnect/DataForFindPathSchema.cs
@@ -0,0 +1,112 @@
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using sones.GraphDB.TypeSystem;
+
+namespace sones.Plugins.SonesGQL.Functions.TypesConnect
+{
+ #region DataDijkstraForFindPathSchema
+
+ public class DataForFindPathSchema
+ {
+
+ private Dictionary<long, Tuple<IVertexType, double, ulong, long, IVertexType>> _list;
+ private int _count;
+
+ public int Count { get { return Count; } }
+
+
+ public DataForFindPathSchema()
+ {
+ _list = new Dictionary<long, Tuple<IVertexType, double, ulong, long, IVertexType>>();
+ _count = 0;
+
+ }
+ public void Add(IVertexType current_node, double current_distance, UInt64 current_depth, long current_edge, IVertexType father)
+ {
+ var id = current_node.ID;
+ _list.Add(id, Tuple.Create(current_node, current_distance, current_depth, current_edge, father));
+ _count++;
+ }
+
+
+ public void Set(IVertexType value, double current_distance, ulong current_depth, long current_edge, IVertexType father)
+ {
+ var key = value.ID;
+ _list[key] = Tuple.Create(value, current_distance, current_depth, current_edge, father);
+
+ }
+
+ public ulong GetDepth(long current_vertex)
+ {
+
+ return _list[current_vertex].Item3;
+ }
+
+ public ulong GetDepth(int current_vertexID)
+ {
+ return _list.ElementAt(current_vertexID).Value.Item3;
+ }
+
+ public double GetDistance(long current_vertex)
+ {
+ return _list[current_vertex].Item2;
+ }
+
+ public double GetDistance(int current_vertexID)
+ {
+
+ return _list.ElementAt(current_vertexID).Value.Item2;
+ }
+
+ public Tuple<IVertexType, double, ulong, long, IVertexType> GetElement(long key)
+ {
+ Tuple<IVertexType, double, ulong, long, IVertexType> temp;
+ _list.TryGetValue(key, out temp);
+ return temp;
+ }
+
+ private Tuple<IVertexType, double, ulong, long, IVertexType> GetTuple(int key)
+ {
+ return this._list.ElementAt(key).Value;
+ }
+
+ private Tuple<IVertexType, double, ulong, long, IVertexType> GetTuple(long key)
+ {
+ return this._list[key];
+ }
+
+ public void Clear()
+ {
+ _list.Clear();
+ _count = 0;
+ }
+
+ private bool ConstainsKey(long key)
+ {
+ return this._list.ContainsKey(key);
+ }
+ }
+ #endregion
+}
View
35 ...aphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/TypesConnect/TypeWithProperty.cs
@@ -1,4 +1,24 @@
-using System;
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,15 +28,16 @@
using sones.Library.Commons.Security;
using sones.Library.Commons.Transaction;
-namespace TypesConnect
+namespace sones.Plugins.SonesGQL.Functions.TypesConnect
{
public class TypeWithProperty
{
- public IVertexType type { get; set; }
- public IPropertyDefinition propertyDifinition { get; set; }
+ public IVertexType Type { get; set; }
+ public IPropertyDefinition PropertyDefinition { get; set; }
#region StringParser
+
public List<TypeWithProperty> StringParser(String current_string, IGraphDB myDB, SecurityToken mySecurityToken, Int64 myTransactionToken)
{
current_string = current_string.Replace(" ","");
@@ -58,8 +79,8 @@ public List<TypeWithProperty> StringParser(String current_string, IGraphDB myDB,
if (property==null)
throw new InvalidFunctionParameterException("Property", "Property: " + propertyIDString + " not exist in VertexType:" + typeVertexString, "null");
TypeWithProperty value = new TypeWithProperty();
- value.propertyDifinition = property;
- value.type = typeVertex;
+ value.PropertyDefinition = property;
+ value.Type = typeVertex;
if (!list.Contains(value))
list.Add(value);
@@ -73,5 +94,5 @@ public List<TypeWithProperty> StringParser(String current_string, IGraphDB myDB,
return list;
}
}
- #endregion
+ #endregion
}
View
210 ...phAlgorithms/TypesConnect/typesconnect.cs → ...phAlgorithms/TypesConnect/TypesConnect.cs
@@ -1,4 +1,24 @@
-using System;
+/*
+* sones GraphDB - Community Edition - http://www.sones.com
+* Copyright (C) 2007-2011 sones GmbH
+*
+* This file is part of sones GraphDB Community Edition.
+*
+* sones GraphDB is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Affero General Public License as published by
+* the Free Software Foundation, version 3 of the License.
+*
+* sones GraphDB is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Affero General Public License for more details.
+*
+* You should have received a copy of the GNU Affero General Public License
+* along with sones GraphDB. If not, see <http://www.gnu.org/licenses/>.
+*
+*/
+
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -16,26 +36,22 @@
using sones.Plugins.SonesGQL.Functions;
using sones.Library.CollectionWrapper;
-
-
-namespace TypesConnect
+namespace sones.Plugins.SonesGQL.Functions.TypesConnect
{
- public sealed class typesconnect : ABaseFunction, IPluginable
- {
+ public sealed class TypesConnect : ABaseFunction, IPluginable
+ {
- List<List<Tuple<long,long>>> path = new List<List<Tuple<long,long>>>();
- List<Tuple<String, String>> stringPath = new List<Tuple<string, string>>();
+ private List<List<Tuple<long,long>>> _path = new List<List<Tuple<long,long>>>();
+ private List<Tuple<String, String>> _stringPath = new List<Tuple<string, string>>();
#region depth-first search
- void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
+ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
{
var outEdges = start.GetOutgoingEdgeDefinitions(true);
var incEdges = start.GetIncomingEdgeDefinitions(true);
-
-
foreach (IOutgoingEdgeDefinition vertexType in outEdges)
{
@@ -45,8 +61,8 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
var current_parents = Parents.ToList();
Parents.Add(Tuple.Create(vertexType.TargetVertexType.ID,vertexType.ID));
- if (Parents.Last().Item1 == end.ID && !path.Contains(Parents))
- path.Add(Parents);
+ if (Parents.Last().Item1 == end.ID && !_path.Contains(Parents))
+ _path.Add(Parents);
else
{
DFS(vertexType.TargetVertexType, end, Parents);
@@ -62,9 +78,9 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
Parents.Add(Tuple.Create(vertexType.RelatedEdgeDefinition.SourceVertexType.ID,vertexType.ID));
- if (Parents.Last().Item1 == end.ID && !path.Contains(Parents))
+ if (Parents.Last().Item1 == end.ID && !_path.Contains(Parents))
{
- path.Add(Parents);
+ _path.Add(Parents);
}
else
{
@@ -75,7 +91,9 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
}
}
#endregion
+
#region Dijkstra for VertexTypes
+
private Tuple<double, List<Tuple<long, long>>, IVertexType, IVertexType> ShortPath(IVertexType start, IVertexType end)
{
#region initialization
@@ -92,20 +110,16 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- bufferForFindPathShema buf = new bufferForFindPathShema();
- dataForFindPathShema lists = new dataForFindPathShema();
-
-
-
- buf.add(start, 0, 0);
- lists.add(start, 0, 0, 0, start);
-
-
-
+ BufferForFindPathSchema buf = new BufferForFindPathSchema();
+ DataForFindPathSchema lists = new DataForFindPathSchema();
+
+ buf.Add(start, 0, 0);
+ lists.Add(start, 0, 0, 0, start);
bool endVertexFlag = false;
#endregion
+
#region Dijkstra algorithm
@@ -136,7 +150,7 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
var current_Edge = hyperEdgeOut.ElementAt(iCount).ID;
- var TargetVertexID = lists.getElement(TargetVertexType.ID);
+ var TargetVertexID = lists.GetElement(TargetVertexType.ID);
if (TargetVertexID == null)
{
@@ -146,13 +160,13 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.add(TargetVertexType,
+ buf.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertexType,
+ lists.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -167,12 +181,12 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.add(TargetVertexType,
+ buf.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertexType,
+ lists.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -191,11 +205,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -212,11 +226,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
endvertexDepth > currentVertexDepth + 1))
{
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -231,11 +245,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -252,11 +266,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -272,7 +286,7 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
endVertexFlag = true;
- var endNode = lists.getElement(end.ID);
+ var endNode = lists.GetElement(end.ID);
endVertexDistance = endNode.Item2;
endvertexDepth = endNode.Item3;
@@ -291,7 +305,7 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
var current_Edge = hyperEdgeInc.ElementAt(iCount).ID;//.RelatedEdgeDefinition.EdgeType;
- var TargetVertexID = lists.getElement(TargetVertexType.ID);
+ var TargetVertexID = lists.GetElement(TargetVertexType.ID);
if (TargetVertexID == null)
{
@@ -301,13 +315,13 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.add(TargetVertexType,
+ buf.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertexType,
+ lists.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -322,12 +336,12 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.add(TargetVertexType,
+ buf.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.add(TargetVertexType,
+ lists.Add(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -346,11 +360,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -367,11 +381,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
endvertexDepth > currentVertexDepth + 1))
{
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -386,11 +400,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -407,11 +421,11 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
- buf.set(TargetVertexID.Item2, TargetVertexType,
+ buf.Set(TargetVertexID.Item2, TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1);
- lists.set(TargetVertexType,
+ lists.Set(TargetVertexType,
current_distance + currentVertexDistance,
currentVertexDepth + 1,
current_Edge,
@@ -427,7 +441,7 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
endVertexFlag = true;
- var endNode = lists.getElement(end.ID);
+ var endNode = lists.GetElement(end.ID);
endVertexDistance = endNode.Item2;
endvertexDepth = endNode.Item3;
@@ -449,25 +463,23 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
else
{
- buf.remove(currentVertexDistance, currentVertex.ID);
+ buf.Remove(currentVertexDistance, currentVertex.ID);
}
//Minimum distance from Buffer
if (buf.Count != 0)
{
- var minVertex = buf.min();
+ var minVertex = buf.Min();
currentVertex = minVertex.Item1;
currentVertexDistance = minVertex.Item2;
currentVertexDepth = minVertex.Item3;
}
}
#endregion
-
-
-
+
#region create output
List<Tuple<long, long>> parents = new List<Tuple<long, long>>();
@@ -476,7 +488,7 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
while (currentVertex != start)
{
- var current_tuple = lists.getElement(currentVertex.ID);
+ var current_tuple = lists.GetElement(currentVertex.ID);
if (current_tuple == null)
return null;
@@ -500,12 +512,13 @@ void DFS(IVertexType start, IVertexType end, List<Tuple<long,long>> Parents)
}
- #endregion
+ #endregion
+
#endregion
#region constructor
- public typesconnect()
+ public TypesConnect()
{
Parameters.Add(new ParameterValue("Types", typeof(String)));
Parameters.Add(new ParameterValue("Method", typeof(bool)));
@@ -514,38 +527,40 @@ public typesconnect()
#endregion
#region ValidateWorkingBase
+
public override bool ValidateWorkingBase(Object myWorkingBase, IGraphDB myGraphDB, SecurityToken mySecurityToken, Int64 myTransactionToken)
{
return myWorkingBase == null;
}
+
#endregion
#region find all Path in the set of edges
- private void helper(IGraphDB graph, SecurityToken sec, Int64 trans, List<TypeWithProperty> type_property_object, List<Tuple<long, long>> PATHShort)
- {
- List<Tuple<String, String>> output = new List<Tuple<string, string>>();
- this.stringPath.Clear();
+ private void Helper(IGraphDB graph, SecurityToken sec, Int64 trans, List<TypeWithProperty> type_property_object, List<Tuple<long, long>> PATHShort)
+ {
+ List<Tuple<String, String>> output = new List<Tuple<string, string>>();
+ this._stringPath.Clear();
var StartTypeLong = PATHShort.Find(x => x.Item2 == 0);
var StartType = graph.GetVertexType(sec,
trans,
new sones.GraphDB.Request.RequestGetVertexType(StartTypeLong.Item1),
(statistics, type) => type);
- this.stringPath.Add(Tuple.Create("Starting VertexType for SELECT", StartType.Name));
+ this._stringPath.Add(Tuple.Create("Starting VertexType for SELECT", StartType.Name));
String str = StartType.Name;
- foreach (TypeWithProperty value in type_property_object.Where(x => x.type.ID == StartType.ID))
- this.stringPath.Add(Tuple.Create(StartType.Name + '.' + value.propertyDifinition.Name,StartType.Name + '.' + value.propertyDifinition.Name));
+ foreach (TypeWithProperty value in type_property_object.Where(x => x.Type.ID == StartType.ID))
+ this._stringPath.Add(Tuple.Create(StartType.Name + '.' + value.PropertyDefinition.Name,StartType.Name + '.' + value.PropertyDefinition.Name));
- recurs(str, StartType, type_property_object, PATHShort);
+ Recurs(str, StartType, type_property_object, PATHShort);
}
- private String recurs(String str,IVertexType StartType, List<TypeWithProperty> type_property_object, List<Tuple<long, long>> PATHShortDSF)
+ private String Recurs(String str,IVertexType StartType, List<TypeWithProperty> type_property_object, List<Tuple<long, long>> PATHShortDSF)
{
var hyperEdgeOut = StartType.GetOutgoingEdgeDefinitions(true);
var hyperEdgeInc = StartType.GetIncomingEdgeDefinitions(true);
@@ -554,22 +569,22 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
{
if (PATHShortDSF.Find(x => x.Item2 == value.ID) != null)
{
- if (type_property_object.Where(x => x.type.ID == value.TargetVertexType.ID).Count() > 0)
+ if (type_property_object.Where(x => x.Type.ID == value.TargetVertexType.ID).Count() > 0)
{
var temp = str;
- foreach (TypeWithProperty val in type_property_object.Where(x => x.type.ID == value.TargetVertexType.ID))
+ foreach (TypeWithProperty val in type_property_object.Where(x => x.Type.ID == value.TargetVertexType.ID))
{
- stringPath.Add(Tuple.Create(val.type.Name+'.'+val.propertyDifinition.Name,str + '.' + value.Name + '.' + val.propertyDifinition.Name));
+ _stringPath.Add(Tuple.Create(val.Type.Name+'.'+val.PropertyDefinition.Name,str + '.' + value.Name + '.' + val.PropertyDefinition.Name));
}
str = temp + '.' + value.Name;
- recurs(str, value.TargetVertexType, type_property_object, PATHShortDSF);
+ Recurs(str, value.TargetVertexType, type_property_object, PATHShortDSF);
str = temp;
}
else
{
var temp = str;
str += '.' + value.Name;
- recurs(str, value.TargetVertexType, type_property_object, PATHShortDSF);
+ Recurs(str, value.TargetVertexType, type_property_object, PATHShortDSF);
str = temp;
}
}
@@ -579,31 +594,34 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
{
if (PATHShortDSF.Find(x => x.Item2 == value.ID) != null)
{
- if (type_property_object.Where(x => x.type.ID == value.RelatedEdgeDefinition.SourceVertexType.ID).Count() > 0)
+ if (type_property_object.Where(x => x.Type.ID == value.RelatedEdgeDefinition.SourceVertexType.ID).Count() > 0)
{
var temp = str;
- foreach (TypeWithProperty val in type_property_object.Where(x => x.type.ID == value.RelatedEdgeDefinition.SourceVertexType.ID))
+ foreach (TypeWithProperty val in type_property_object.Where(x => x.Type.ID == value.RelatedEdgeDefinition.SourceVertexType.ID))
{
- stringPath.Add(Tuple.Create(val.type.Name + '.' + val.propertyDifinition.Name, str + '.' + value.Name + '.' + val.propertyDifinition.Name));
+ _stringPath.Add(Tuple.Create(val.Type.Name + '.' + val.PropertyDefinition.Name, str + '.' + value.Name + '.' + val.PropertyDefinition.Name));
}
str = temp + '.' + value.Name;
- recurs(str, value.RelatedEdgeDefinition.SourceVertexType, type_property_object, PATHShortDSF);
+ Recurs(str, value.RelatedEdgeDefinition.SourceVertexType, type_property_object, PATHShortDSF);
str = temp;
}
else
{
var temp = str;
str += '.' + value.Name;
- recurs(str, value.RelatedEdgeDefinition.SourceVertexType, type_property_object, PATHShortDSF);
+ Recurs(str, value.RelatedEdgeDefinition.SourceVertexType, type_property_object, PATHShortDSF);
str = temp;
}
}
}
str = "";
return null;
}
+
#endregion
+
#region ExecFunc
+
public override FuncParameter ExecFunc(IAttributeDefinition myAttributeDefinition,
Object myCallingObject,
IVertex myDBObject,
@@ -636,19 +654,19 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
foreach (TypeWithProperty vertexEnd in ObjectList)
{
- if (vertexStart != vertexEnd && vertexStart.type.ID!=vertexEnd.type.ID)
+ if (vertexStart != vertexEnd && vertexStart.Type.ID!=vertexEnd.Type.ID)
{
if (method)
{
- var output = this.ShortPath(vertexStart.type, vertexEnd.type);
+ var output = this.ShortPath(vertexStart.Type, vertexEnd.Type);
if (output != null)
all.Add(output);
}
else
{
List<Tuple<long, long>> value = new List<Tuple<long, long>>();
- value.Add(Tuple.Create(vertexStart.type.ID, 0L));
- this.DFS(vertexStart.type, vertexEnd.type, value);
+ value.Add(Tuple.Create(vertexStart.Type.ID, 0L));
+ this.DFS(vertexStart.Type, vertexEnd.Type, value);
}
@@ -664,7 +682,7 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
{
#region DFS
#region path->allPath->PATH for better representation
- foreach (List<Tuple<long, long>> value in path)
+ foreach (List<Tuple<long, long>> value in _path)
{
if (!allPath.ContainsKey(Tuple.Create(value.First().Item1, value.Last().Item1)))
{
@@ -713,7 +731,7 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
{
var test = 0;
- foreach (long wert in ObjectList.Select(x => x.type.ID))
+ foreach (long wert in ObjectList.Select(x => x.Type.ID))
{
if (PATH[iCount].Where(x => x.Item1 == wert).Count() > 0)
test++;
@@ -759,7 +777,7 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
var test = 0;
test = 0;
- foreach (long value in ObjectList.Select(x => x.type.ID))
+ foreach (long value in ObjectList.Select(x => x.Type.ID))
{
if (PATH[jCount].Where(x => x.Item1 == value).Count() > 0)
test++;
@@ -839,7 +857,7 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
var minPATH = PATH.Min(x => x.Count);
var indexPATH = PATH.First(x => x.Count == minPATH);
- this.helper(myGraphDB, mySecurityToken, myTransactionToken, ObjectList, indexPATH);
+ this.Helper(myGraphDB, mySecurityToken, myTransactionToken, ObjectList, indexPATH);
}
#endregion
@@ -880,7 +898,7 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
{
var test = 0;
- foreach (long wert in ObjectList.Select(x => x.type.ID))
+ foreach (long wert in ObjectList.Select(x => x.Type.ID))
{
if (PATHShort[iCount].Where(x => x.Item1 == wert).Count() > 0)
test++;
@@ -923,7 +941,7 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
var test = 0;
test = 0;
- foreach (long value in ObjectList.Select(x => x.type.ID))
+ foreach (long value in ObjectList.Select(x => x.Type.ID))
{
if (PATHShort[jCount].Where(x => x.Item1 == value).Count() > 0)
test++;
@@ -1004,16 +1022,16 @@ private String recurs(String str,IVertexType StartType, List<TypeWithProperty> t
var minPATHShort = PATHShort.Min(x => x.Count);
var indexPATHShort = PATHShort.First(x => x.Count == minPATHShort);
- this.helper(myGraphDB, mySecurityToken, myTransactionToken, ObjectList,indexPATHShort);
+ this.Helper(myGraphDB, mySecurityToken, myTransactionToken, ObjectList,indexPATHShort);
}
#endregion
#endregion
#region Output
- var result = new ListCollectionWrapper(stringPath.Select(x => x.Item1+" = "+ x.Item2));
- this.path.Clear();
- this.stringPath.Clear();
+ var result = new ListCollectionWrapper(_stringPath.Select(x => x.Item1+" = "+ x.Item2));
+ this._path.Clear();
+ this._stringPath.Clear();
return new FuncParameter(result);
#endregion
}
@@ -1033,7 +1051,7 @@ public override PluginParameters<Type> SetableParameters
public override IPluginable InitializePlugin(String myUniqueString, Dictionary<string, object> myParameters = null)
{
- return new typesconnect();
+ return new TypesConnect();
}
public override string PluginShortName
@@ -1060,6 +1078,4 @@ public override Type GetReturnType()
#endregion
}
-
-
}
View
6 ...aphQL/SonesGQL/Functions/Implementations/GraphAlgorithms/TypesConnect/TypesConnect.csproj
@@ -40,10 +40,10 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
- <Compile Include="bufferForFindPathShema.cs" />
- <Compile Include="dataForFindPathShema.cs" />
- <Compile Include="typesconnect.cs" />
+ <Compile Include="BufferForFindPathSchema.cs" />
+ <Compile Include="DataForFindPathSchema.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TypesConnect.cs" />
<Compile Include="TypeWithProperty.cs" />
</ItemGroup>
<ItemGroup>
View
93 ...SonesGQL/Functions/Implementations/GraphAlgorithms/TypesConnect/bufferForFindPathShema.cs
@@ -1,93 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using sones.GraphDB.TypeSystem;
-
-namespace TypesConnect
-{
- #region bufferForFindPathShema
- public class bufferForFindPathShema
- {
-
- SortedDictionary<Tuple<double, long>, Tuple<IVertexType, double, ulong>> buf;
-
-
- public int Count { get { return count; } }
- int count;
-
- public bufferForFindPathShema()
- {
- buf = new SortedDictionary<Tuple<double, long>, Tuple<IVertexType, double, ulong>>();
-
- count = 0;
-
- }
-
- public void add(IVertexType current_node, double current_distance, UInt64 current_depth)
- {
- var id = current_node.ID;
- buf.Add(Tuple.Create(current_distance, id), Tuple.Create(current_node, current_distance, current_depth));
-
- count++;
-
-
-
- }
- public Tuple<IVertexType, double, ulong> min()
- {
- return buf.ElementAt(0).Value;
- }
-
-
- public void remove(double key_primary, long key_secondary)
- {
- buf.Remove(Tuple.Create(key_primary, key_secondary));
- count--;
- }
-
- public void set(double key_primary, IVertexType value, double current_distance, ulong current_depth)
- {
- var key = value.ID;
- buf.Remove(Tuple.Create(key_primary, key));
- buf.Add(Tuple.Create(current_distance, key), Tuple.Create(value, current_distance, current_depth));
- }
-
- public ulong getDepth(double key_primary, long current_vertex)
- {
- return buf[Tuple.Create(key_primary, current_vertex)].Item3;
- }
-
- public ulong getDepth(int current_vertexID)
- {
- return buf.ElementAt(current_vertexID).Value.Item3;
- }
-
- public double getDistance(double key_primary, long current_vertex)
- {
- return buf[Tuple.Create(key_primary, current_vertex)].Item2;
- }
-
- public double getDistance(int current_vertexID)
- {
- return buf.ElementAt(current_vertexID).Value.Item2;
- }
-
- public Tuple<IVertexType, double, ulong> getElement(double key_primary, long index)
- {
- Tuple<IVertexType, double, ulong> output;
- buf.TryGetValue(Tuple.Create(key_primary, index), out output);
- return output;
- }
-
- public void Clear()
- {
- buf.Clear();
- count = 0;
- }
-
-
-
- }
- #endregion
-}
View
95 ...L/SonesGQL/Functions/Implementations/GraphAlgorithms/TypesConnect/dataForFindPathShema.cs
@@ -1,95 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using sones.GraphDB.TypeSystem;
-
-namespace TypesConnect
-{
- #region dataDijkstraForFindPathShema
- public class dataForFindPathShema
- {
-
- Dictionary<long, Tuple<IVertexType, double, ulong, long, IVertexType>> list;
- public int Count { get { return Count; } }
-
- int count;
-
- public dataForFindPathShema()
- {
- list = new Dictionary<long, Tuple<IVertexType, double, ulong, long, IVertexType>>();
- count = 0;
-
- }
- public void add(IVertexType current_node, double current_distance, UInt64 current_depth, long current_edge, IVertexType father)
- {
- var id = current_node.ID;
- list.Add(id, Tuple.Create(current_node, current_distance, current_depth, current_edge, father));
- count++;
- }
-
-
- public void set(IVertexType value, double current_distance, ulong current_depth, long current_edge, IVertexType father)
- {
- var key = value.ID;
- list[key] = Tuple.Create(value, current_distance, current_depth, current_edge, father);
-
- }
-
- public ulong getDepth(long current_vertex)
- {
-
- return list[current_vertex].Item3;
- }
-
- public ulong getDepth(int current_vertexID)
- {
-
- return list.ElementAt(current_vertexID).Value.Item3;
- }
-
- public double getDistance(long current_vertex)
- {
-
- return list[current_vertex].Item2;
- }
-
- public double getDistance(int current_vertexID)
- {
-
- return list.ElementAt(current_vertexID).Value.Item2;
- }
-
- public Tuple<IVertexType, double, ulong, long, IVertexType> getElement(long key)
- {
- Tuple<IVertexType, double, ulong, long, IVertexType> temp;
- list.TryGetValue(key, out temp);
- return temp;
- }
-
- private Tuple<IVertexType, double, ulong, long, IVertexType> getTuple(int key)
- {
- return this.list.ElementAt(key).Value;
- }
-
- private Tuple<IVertexType, double, ulong, long, IVertexType> getTuple(long key)
- {
- return this.list[key];
- }
-
- public void Clear()
- {
- list.Clear();
- count = 0;
- }
-
- private bool ConstainsKey(long key)
- {
-
- return this.list.ContainsKey(key);
- }
-
-
- }
- #endregion
-}

0 comments on commit 3f9100c

Please sign in to comment.