Skip to content

Commit

Permalink
Merge branch 'master' of git.sones:sones-community-edition into Remot…
Browse files Browse the repository at this point in the history
…eAPI_bug_fix
  • Loading branch information
Markus Zorn committed Nov 22, 2011
2 parents e1eaeac + bae6d88 commit 3f9100c
Show file tree
Hide file tree
Showing 13 changed files with 613 additions and 474 deletions.
7 changes: 6 additions & 1 deletion GraphQL/IGraphQL/Result/QueryResult.cs
Expand Up @@ -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>();
Expand Down
@@ -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;
Expand All @@ -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
}
@@ -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
}

0 comments on commit 3f9100c

Please sign in to comment.