public NavGraphEdge( int fromIdx, int toIdx, float cost, EdgeType edgeType=EdgeType.normal ) { fromIdx_ = fromIdx; toIdx_ = toIdx; cost_ = cost; edgeType_ = edgeType; }
public void add(String name, String seriesName, int issueYear, int width, int height, EdgeType type, int faceValue, double multiplier) { if (this.index < StampCatalog.MAX_NUMBER_OF_STAMPS) { this.stamps[this.index++] = new Stamp(name, seriesName, issueYear, width, height, type, faceValue, multiplier); } }
public Edge() { type = EdgeType.Normal; name = "Edge"; id = 0; behaviors = new List<Behavior>(); }
public EdgeTemplate(EdgeType type, int width, int height) { Type = type; Width = width; Height = height; Points = GetPoints(type, width, height); }
public EdgeDescription(Vector3 pos, Direction direction, EdgeType type) { position = pos; dir = direction; this.type = type; }
public FileIO(IGraph g) { try { graph = g; outputnodetype = g.Model.NodeModel.GetType("grIO_OUTPUT"); if (outputnodetype == null) throw new Exception(); createOrOverwriteType = g.Model.EdgeModel.GetType("grIO_CreateOrOverwrite"); if (createOrOverwriteType == null) throw new Exception(); createOrAppendType = g.Model.EdgeModel.GetType("grIO_CreateOrAppend"); if (createOrAppendType == null) throw new Exception(); fileType = g.Model.NodeModel.GetType("grIO_File"); if (fileType == null) throw new Exception(); fileNameAttrType = fileType.GetAttributeType("path"); if (fileNameAttrType == null) throw new Exception(); lineType = g.Model.NodeModel.GetType("grIO_File_Line"); if (lineType == null) throw new Exception(); containsLineType = g.Model.EdgeModel.GetType("grIO_File_ContainsLine"); if (containsLineType == null) throw new Exception(); nextLineType = g.Model.EdgeModel.GetType("grIO_File_NextLine"); if (nextLineType == null) throw new Exception(); lineContentAttrType = lineType.GetAttributeType("content"); if (lineContentAttrType == null) throw new Exception(); } catch (Exception) { throw new Exception("Could not find the required node/edge types. Did you include the GrIO-model?"); } }
public Edge() { type = EdgeType.Normal; id = 0; _name = "Edge_" + id; behaviors = new List<Behavior>(); }
public Square(Point point, int size, Color surfaceColor, Color borderColor, EdgeType edgeType) : this() { this.Location = point; this.Size = size; this.SurfaceColor = surfaceColor; this.BorderColor = borderColor; this.EdgeType = edgeType; }
public SweepEvent(Point p, bool isLeft, PolygonType polygonType, SweepEvent otherSweepEvent, EdgeType edgeType) { this.p = p; this.isLeft = isLeft; this.polygonType = polygonType; this.otherSE = otherSweepEvent; this.edgeType = edgeType; }
/// <summary> /// Creates a new edge between source and target. The edge is not registered with the source and /// target vertices unless it is added to the graph! /// </summary> /// <param name="a">The A vertex</param> /// <param name="b">The B vertex</param> /// <param name="graph">The graph to which this edge belongs</param> /// <param name="type">Whether to create an undirected or a directed edge</param> public Edge(Vertex a, Vertex b, Network graph, EdgeType type) { ID = Guid.NewGuid(); A = a; B = b; Network = graph; EdgeType = type; }
/// <summary> /// Creates a new edge between source and target. The edge is not registered with the source and /// target vertices unless it is added to the graph! /// </summary> /// <param name="a">The A vertex</param> /// <param name="b">The B vertex</param> /// <param name="graph">The graph to which this edge belongs</param> /// <param name="type">Whether to create an undirected or a directed edge</param> /// <param name="id">The ID that this vertex will be assigned</param> public Edge(Vertex a, Vertex b, Network graph, EdgeType type, Guid id) { ID = id; A = a; B = b; Network = graph; EdgeType = type; }
internal void EnsureEdgeInfo(uint edgeId, uint startSlotId, uint endSlotId, EdgeType edgeType) { VisualEdge edge = controller.GetVisualEdge(edgeId); Assert.AreNotEqual(null, edge); // Make sure the edge exists. Assert.AreEqual(startSlotId, edge.StartSlotId); // Connecting from... Assert.AreEqual(endSlotId, edge.EndSlotId); // Connecting to... Assert.AreEqual(edgeType, edge.EdgeType); // Explicit or implicit? }
public AbstractEdge(string name, long unid, bool showAnnotation, int weight, Position position, Transition transition, EdgeType edgeType) : base(name, unid, showAnnotation) { this.weight = weight; this.position = position; this.transition = transition; this.edgeType = edgeType; }
internal VisualEdge(EdgeController edgeController, EdgeType edgeType) { this.edgeController = edgeController; this.EdgeType = edgeType; controlPoints.Add(new Point()); controlPoints.Add(new Point()); controlPoints.Add(new Point()); controlPoints.Add(new Point()); }
/// <summary> /// Returns the edges in the graph of the type given, as set /// </summary> public static Dictionary<IEdge, SetValueType> Edges(IGraph graph, EdgeType edgeType, int threadId) { Dictionary<IEdge, SetValueType> edgesSet = new Dictionary<IEdge, SetValueType>(); foreach(IEdge edge in graph.GetCompatibleEdges(edgeType)) { edgesSet[edge] = null; } return edgesSet; }
public Edge(Vertex start, Vertex end, EdgeType type) { Start = start; End = end; Type = type; Start.Add(this); End.Add(this); }
public Stamp(String name, String seriesName, int issueYear, int width, int height, EdgeType type, int faceValue, double multiplier) { this.name = name; this.seriesName = seriesName; this.issueYear = issueYear; this.data = new StampData(width, height, type); this.faceValue = faceValue; this.multiplier = multiplier; }
public PlanarGraphEdge(GeometryTutorLib.ConcreteAST.Point targ, EdgeType type, double c, int initDegree) { this.target = targ; edgeType = type; cost = c; degree = initDegree; isCycle = false; }
public static Dictionary<IEdge, SetValueType> Edges(IGraph graph, EdgeType edgeType, IActionExecutionEnvironment actionEnv, int threadId) { Dictionary<IEdge, SetValueType> edgesSet = new Dictionary<IEdge, SetValueType>(); foreach(IEdge edge in graph.GetCompatibleEdges(edgeType)) { ++actionEnv.PerformanceInfo.SearchStepsPerThread[threadId]; edgesSet[edge] = null; } return edgesSet; }
public EdgeViewModel(NodeViewModel nVMEndA, NodeViewModel nVMEndB, EdgeType type) { edge = new Edge(); NVMEndA = nVMEndA; NVMEndB = nVMEndB; MultA = ""; MultB = ""; Type = edgeTypeConverter(type); initArrow(); newPath(); }
private Point[] GetPoints(EdgeType type, int width, int height) { switch (type) { case EdgeType.Left: return Sweep(0, 0, 0, 1, height); case EdgeType.Top: return Sweep(0, 0, 1, 0, width); case EdgeType.Right: return Sweep(width - 1, 0, 0, 1, height); case EdgeType.Bottom: return Sweep(0, height - 1, 1, 0, width); default: throw new InvalidOperationException(); } }
public Edge(Edge e) { id = e.id; start = e.start; end = e.end; type = e.type; behaviors = new List<Behavior>(); foreach (Behavior b in e.behaviors) { behaviors.Add(new Behavior(b)); } }
public Stamp[] getStamps(EdgeType type) { int numberOfStamps = this.count(type); Stamp[] result = new Stamp[numberOfStamps]; int index = 0; for (int i = 0; i < this.index; i++) { if (this.stamps[i].Data.Type == type) { result[index++] = this.stamps[i]; } } return result; }
public void AddUndirectedEdge(Point from, Point to, double cost, EdgeType eType) { // // Are these nodes in the graph? // int fromNodeIndex = nodes.IndexOf(new PlanarGraphNode(from)); int toNodeIndex = nodes.IndexOf(new PlanarGraphNode(to)); if (fromNodeIndex == -1 || toNodeIndex == -1) { throw new ArgumentException("Edge uses undefined nodes: " + from + " " + to); } // // Check if the edge already exists // PlanarGraphEdge fromToEdge = nodes[fromNodeIndex].GetEdge(to); if (fromToEdge != null) { PlanarGraphEdge toFromEdge = nodes[toNodeIndex].GetEdge(from); fromToEdge.edgeType = UpdateEdge(fromToEdge.edgeType, eType); toFromEdge.edgeType = fromToEdge.edgeType; // Increment the degree if it is an arc. if (eType == EdgeType.REAL_ARC) { fromToEdge.degree++; toFromEdge.degree++; } } // // The edge does not exist. // else { nodes[fromNodeIndex].AddEdge(to, eType, cost, (eType == EdgeType.REAL_ARC ? 1 : 0)); nodes[toNodeIndex].AddEdge(from, eType, cost, (eType == EdgeType.REAL_ARC ? 1 : 0)); } }
public void AddCurve(EdgeType Type, params Coord[] Points) { AddCurve(Type, Points.AsEnumerable()); }
public void AddLine(EdgeType Type, Coord x1, Coord x2) { InBounds(x1, x2); DrawLine(Type, x1, x2); }
// Add shapes to the schematic. public void AddRectangle(EdgeType Type, Coord x1, Coord x2) { InBounds(x1, x2); DrawRectangle(Type, x1, x2); }
// [Test] public void TestVelecoityBuildLocal() { using (var session = new SessionNoServer(@"d:\graphtest")) { session.BeginUpdate(); session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4; DataCache.MaximumMemoryUse = 2000000000; //var dbl = new DatabaseLocation(Dns.GetHostEntry("wordanalysis.cloudapp.net").HostName, @"Z:\DBStore\", 0, // 3, session); //DatabaseLocation bl = session.NewLocation(dbl); //session.Commit(false); // Assert.That(bl!=null); var graph = new Graph(session); session.Persist(graph); //define schema // session.BeginUpdate(); VertexType namedScore = graph.NewVertexType("NamedScore"); PropertyType name = namedScore.NewProperty("Name", DataType.String, PropertyKind.Indexed); PropertyType int_score = namedScore.NewProperty("IntScore", DataType.Integer, PropertyKind.NotIndexed); PropertyType double_score = namedScore.NewProperty("DoubleScore", DataType.Double, PropertyKind.NotIndexed); VertexType concept = graph.NewVertexType("Concept"); PropertyType conceptName = concept.NewProperty("Name", DataType.String, PropertyKind.Unique); PropertyType conceptSize = concept.NewProperty("ConceptSize", DataType.Integer, PropertyKind.NotIndexed); PropertyType conceptFrequency = concept.NewProperty("ConceptFrequency", DataType.Integer, PropertyKind.NotIndexed); PropertyType similarity = concept.NewProperty("Similarity", DataType.Double, PropertyKind.NotIndexed); PropertyType vagueness = concept.NewProperty("Vagueness", DataType.Double, PropertyKind.NotIndexed); VertexType instance = graph.NewVertexType("Instance", concept); PropertyType instanceSize = instance.NewProperty("InstanceSize", DataType.Integer, PropertyKind.NotIndexed); PropertyType instanceFrequency = instance.NewProperty("InstanceFrequency", DataType.Integer, PropertyKind.NotIndexed); PropertyType instanceName = instance.NewProperty("Name", DataType.String, PropertyKind.Unique); VertexType attributes = graph.NewVertexType("Attribute", namedScore); //EdgeType hasAttirbute = attributes.edgattributes.NewHeadToTailEdge(nameScorePair,); EdgeType cooccursWith = graph.NewEdgeType("CooccursWith", true, instance, instance); PropertyType coocurrenceFrequency = namedScore.NewProperty("IntScore", DataType.Integer, PropertyKind.NotIndexed); VertexType synonym = graph.NewVertexType("Synonym", namedScore); PropertyType synonymScore = synonym.NewProperty("Score", DataType.Integer, PropertyKind.NotIndexed); EdgeType hasSynonym = graph.NewEdgeType("HasSynonym", true, synonym, instance); EdgeType isA = graph.NewEdgeType("IsA", true, concept, instance); PropertyType frequency = isA.NewProperty("frequency", DataType.Integer, PropertyKind.NotIndexed); PropertyType popularity = isA.NewProperty("popularity", DataType.Integer, PropertyKind.NotIndexed); PropertyType ZipfSlope = isA.NewProperty("zipf_slope", DataType.Double, PropertyKind.NotIndexed); PropertyType ZipfPearson = isA.NewProperty("zipf_pearson", DataType.Double, PropertyKind.NotIndexed); EdgeType cooccurence = graph.NewEdgeType("Coocurrence", true, concept, concept); //Vertex vx1 = graph.NewVertex(instance); //vx1.SetProperty("Name", "bla"); //Vertex vx2 = graph.NewVertex(instance); //vx2.SetProperty("bla", "name"); //Edge edge = graph.NewEdge(cooccurence, vx1, vx2); using (var llz = new StreamReader(@"d:\isa_core.txt")) { string lastConcept = string.Empty; while (!llz.EndOfStream) { string ln = llz.ReadLine(); if (string.IsNullOrEmpty(ln)) { continue; } string[] items = ln.Split(new[] { '\t' }); if (items.Length < 4) { continue; } int id = -1; if (!int.TryParse(items[2], out id)) { continue; } var conceptVertex = graph.FindVertex(conceptName, items[0], false); if (conceptVertex == null) { conceptVertex = graph.NewVertex(concept); conceptVertex.SetProperty(conceptName, items[0]); conceptVertex.SetProperty(conceptFrequency, int.Parse(items[4])); conceptVertex.SetProperty(conceptSize, int.Parse(items[5])); double d = double.NaN; double.TryParse(items[6], out d); conceptVertex.SetProperty(vagueness, d); d = double.NaN; double.TryParse(items[7], out d); conceptVertex.SetProperty(ZipfSlope, d); d = double.NaN; double.TryParse(items[8], out d); conceptVertex.SetProperty(ZipfPearson, d); } var instanceVertex = graph.FindVertex(instanceName, items[1], false); if (instanceVertex == null) { instanceVertex = graph.NewVertex(instance); instanceVertex.SetProperty(instanceFrequency, int.Parse(items[9])); instanceVertex.SetProperty(instanceSize, int.Parse(items[10])); } var isaedge = graph.NewEdge(isA, conceptVertex, instanceVertex); isaedge.SetProperty(frequency, int.Parse(items[2])); isaedge.SetProperty(popularity, int.Parse(items[3])); } session.Commit(); } } }
public void CreateEdges() { Create1Vertices(true); using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true)) { session.BeginUpdate(); Graph g = Graph.Open(session); // it takes a while to open graph fresh from databases VertexType userType = g.FindVertexType("User"); VertexType locationType = g.FindVertexType("Location"); EdgeType friendEdgeType = g.FindEdgeType("Friend"); EdgeType userLocationEdgeType = g.FindEdgeType("UserLocation"); int lineNumber = 0; long fiendsCt = 0; foreach (string line in File.ReadLines(inputData)) { string[] fields = line.Split(' '); Vertex aUser = new Vertex(g, userType, ++lineNumber); int locationCt = 1; foreach (string s in fields) { if (s.Length > 0) { ++fiendsCt; Vertex aFriend = new Vertex(g, userType, int.Parse(s)); Vertex aLocation = new Vertex(g, locationType, locationCt++); friendEdgeType.NewEdge(aUser, aFriend); userLocationEdgeType.NewEdge(aUser, aLocation); } } if (lineNumber >= 5000) { break; } } Console.WriteLine("Done importing " + lineNumber + " users with " + fiendsCt + " friends"); session.Commit(); session.BeginRead(); foreach (var x in session.AllObjects <BTreeSet <Range <VertexId> > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeSet <EdgeType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeSet <EdgeIdVertexId> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <EdgeId, VelocityDbList <ElementId> > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <string, PropertyType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <string, EdgeType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <string, VertexType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <VertexId, BTreeSet <EdgeIdVertexId> > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <VertexType, BTreeMap <VertexId, BTreeSet <EdgeIdVertexId> > > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <EdgeType, BTreeMap <VertexType, BTreeMap <VertexId, BTreeSet <EdgeIdVertexId> > > > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } session.Commit(); Validate(); } }
public Edge setEdgeType(EdgeType edgeType) { this.edgeType = edgeType; return(this); }
/// <summary> /// Adds a new edge to the graph. /// </summary> /// <param name="edgeType">The edge type for the new edge.</param> /// <param name="source">The source of the edge.</param> /// <param name="target">The target of the edge.</param> /// <returns>The newly created edge.</returns> public virtual LGSPEdge AddEdge(EdgeType edgeType, LGSPNode source, LGSPNode target) { // LGSPEdge edge = new LGSPEdge(edgeType, source, target); LGSPEdge edge = (LGSPEdge) edgeType.CreateEdge(source, target); AddEdgeWithoutEvents(edge, edgeType.TypeID); EdgeAdded(edge); return edge; }
/// <summary> /// Enumerates all edges compatible to the given edge type. /// </summary> public override IEnumerable<IEdge> GetCompatibleEdges(EdgeType edgeType) { foreach(EdgeType type in edgeType.SubOrSameTypes) { LGSPEdge head = edgesByTypeHeads[type.TypeID]; LGSPEdge cur = head.lgspTypeNext; LGSPEdge next; while(cur != head) { next = cur.lgspTypeNext; yield return cur; cur = next; } } }
public static MeshX Subdivide(MeshX mesh) { if (!mesh.helpersInited) { mesh.InitHelpers(); } MeshX newMesh = new MeshX { name = mesh.name + "/s", content = mesh.content, }; newMesh.StartBuilding(); MeshVertices newVertices = new MeshVertices { mesh = newMesh }; Dictionary <System.UInt32, Vertex> edgeMidPositions = new Dictionary <System.UInt32, Vertex>(); for (int pi = 0; pi < mesh.positions.Count; ++pi) { newMesh.AddPosition(default(Vertex)); } for (int vi = 0; vi < mesh.vertexCount; ++vi) { Vertex v = mesh.GetVertex(vi); newMesh.AddVertex(v); } //face points foreach (Face f in mesh.IterAllFaces()) { Vertex[] vs = mesh.GetVertices(mesh.GetFaceVertexIndices(f)); Vertex v = mesh.Average(vs); System.UInt32 keyF = GetFacePointKey(f); newVertices.AddVertices(v, Pair(v, keyF)); } //edge points foreach (Edge e in mesh.IterAllEdges()) { Edge n = mesh.GetNeighbor(e); Vertex midE = mesh.Average( mesh.GetVertices(mesh.GetEdgeVertexIndices(e)) ); System.UInt32 keyE = GetEdgePointKey(e); edgeMidPositions[keyE] = midE; Vertex v = mesh.Average( new[] { midE, newVertices.GetVertex(GetFacePointKey(e.face)), newVertices.GetVertex(GetFacePointKey(n.face)), }, weights: new[] { 2f, 1f, 1f } ); newVertices.AddVertices(v, Pair(v, keyE)); } // move control-points for (int pi = 0; pi < mesh.positions.Count; ++pi) { var edges = new List <Edge>(); var front = new List <Edge>(); foreach (int vi in mesh.positionVertices[pi]) { foreach (Edge e in mesh.vertexEdges[vi]) { edges.Add(e); foreach (Edge edge in new[] { e, mesh.GetNextInFace(e, -1) }) { EdgeType type = mesh.GetEdgeType(edge); if (type != EdgeType.back) { front.Add(edge); } } } } Vertex controlPoint; Vertex[] ms = new Vertex[front.Count]; for (int e = 0; e < front.Count; ++e) { ms[e] = edgeMidPositions[GetEdgePointKey(front[e])]; } Vertex edgeMidAverage = mesh.Average(ms, maskPosition); Vertex[] fs = new Vertex[edges.Count]; for (int e = 0; e < edges.Count; ++e) { fs[e] = newVertices.GetVertex(GetFacePointKey(edges[e].face), maskPosition); } Vertex faceAverage = mesh.Average(fs, maskPosition); controlPoint = mesh.Average( new[] { faceAverage, edgeMidAverage, mesh.GetPosition(pi) }, maskPosition, new[] { 1f, 2f, edges.Count - 3f } ); newMesh.SetPosition(pi, controlPoint); } //face creation newMesh.submeshes = new Submesh[mesh.submeshes.Length]; for (int si = 0; si < mesh.submeshes.Length; ++si) { int[][] faces = mesh.submeshes[si].faces; int faceCount = 0; foreach (int[] face in faces) { faceCount += face.Length; } newMesh.submeshes[si].faces = new int[faceCount][]; int faceIndex = 0; for (int fi = 0; fi < faces.Length; ++fi) { int[] fis = faces[fi]; int edgeCount = fis.Length; Face f = new Face { submesh = si, index = fi }; int ci = newVertices.vertexIndices[GetFacePointKey(f)]; int[] eis = new int[edgeCount]; for (int i = 0; i < edgeCount; ++i) { Edge e = new Edge { face = f, index = i }; eis[i] = newVertices.vertexIndices[GetEdgePointKey(e)]; } for (int i = 0; i < edgeCount; ++i) { int[] q = new int[4]; int s = edgeCount == 4 ? i : 0; q[(0 + s) % 4] = fis[i]; q[(1 + s) % 4] = eis[i]; q[(2 + s) % 4] = ci; q[(3 + s) % 4] = eis[(i - 1 + edgeCount) % edgeCount]; newMesh.submeshes[si].faces[faceIndex++] = q; } } } return(newMesh); }
public void ingestData() { if (Directory.Exists(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir))) { Directory.Delete(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir), true); // remove systemDir from prior runs and all its databases. } Directory.CreateDirectory(Path.Combine(SessionBase.BaseDatabasePath, s_systemDir)); using (SessionNoServer session = new SessionNoServer(s_systemDir, 5000, false, false, CacheEnum.No)) { session.BeginUpdate(); session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4; Graph g = new Graph(session); // SCHEMA VertexType userType = g.NewVertexType("User"); EdgeType friendEdgeType = g.NewEdgeType("Friend", true, userType, userType); PropertyType countryProperty = userType.NewProperty("country", DataType.String, PropertyKind.NotIndexed); PropertyType incomeProperty = userType.NewProperty("income", DataType.Long, PropertyKind.NotIndexed); PropertyType friendshipStartProperty = friendEdgeType.NewProperty("start", DataType.DateTime, PropertyKind.NotIndexed); // DATA int lineNumber = 0; long fiendsCt = 0; int stop = (int)Math.Pow(2, 26); // make sure to create enough of these for (int i = 1; i < stop; i++) { g.NewVertex(userType); } session.Commit(); session.BeginUpdate(); foreach (string line in File.ReadLines(s_inputData)) { if (++lineNumber % 10000 == 0) { Console.WriteLine("Parsing user " + lineNumber + ", friends total: " + fiendsCt + " at " + DateTime.Now); } string[] fields = line.Split(' '); Vertex aUser = null; foreach (string s in fields) { if (s.Length > 0) { if (aUser == null) { aUser = new Vertex(g, userType, int.Parse(s)); } else { ++fiendsCt; Vertex aFriend = new Vertex(g, userType, int.Parse(s)); if (fiendsCt % 2 == 0) { aFriend.SetProperty(countryProperty, "Sweden"); // just some random stuff } else { aFriend.SetProperty(incomeProperty, fiendsCt); // just some random stuff } Edge edge = friendEdgeType.NewEdge(aUser, aFriend); if (fiendsCt % 2 == 0) { edge.SetProperty(friendshipStartProperty, DateTime.Now); } } } } if (DataCache.MaximumMemoryUse <= 27000000000) { if (lineNumber >= 100000) // remove this condition if you have time to wait a long while... { break; } } } Console.WriteLine("Done importing " + lineNumber + " users with " + fiendsCt + " friends"); session.Commit(); } }
// Queries public void doQueries() { using (SessionNoServer session = new SessionNoServer(s_systemDir)) { session.BeginRead(); Graph g = Graph.Open(session); // it takes a while to open graph fresh from databases VertexType userType = g.FindVertexType("User"); EdgeType friendEdgeType = g.FindEdgeType("Friend"); PropertyType countryProperty = userType.FindProperty("country"); PropertyType incomeProperty = userType.FindProperty("income"); PropertyType friendshipStartProperty = friendEdgeType.FindProperty("start"); Vertex someUser = userType.GetVertex(1); Vertex someUser2 = userType.GetVertex(12282); var someUserFriends = from Edge e in someUser.GetEdges(friendEdgeType, Direction.Out) select e.Head; var someUser3LevelNetwork = someUser.Traverse(3, true, Direction.Out); HashSet <Edge> edges = new HashSet <Edge>(); Edge edge = (Edge)someUser.GetEdges(friendEdgeType, Direction.Out).Skip(1).First(); edges.Add(edge); HashSet <EdgeType> edgeTypesToTraverse = new HashSet <EdgeType>(); edgeTypesToTraverse.Add(friendEdgeType); // Find Shortest path between two given user ids List <List <Edge> > path = someUser.Traverse(4, false, Direction.Out, someUser2, edgeTypesToTraverse); Debug.Assert(path.Count > 0); var path2 = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(41), edgeTypesToTraverse); HashSet <Vertex> vertices = new HashSet <Vertex>(); vertices.Add(someUser2); var path3 = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, vertices); // path must include vertices var path3b = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, vertices); // path must NOT include vertices var path3c = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, edges); // path must include edges var path3d = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges); // path must NOT include edges HashSet <PropertyType> vertexPropertyTypes = new HashSet <PropertyType>(); vertexPropertyTypes.Add(incomeProperty); vertexPropertyTypes.Add(countryProperty); var path3e = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges, vertexPropertyTypes); // path must NOT include edges and at least one vertex in path must have property in propertyTypes var path3f = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges, null, vertexPropertyTypes); // path must NOT include edges and no vertex in path must have any property in propertyTypes HashSet <PropertyType> edgePropertyTypes = new HashSet <PropertyType>(); edgePropertyTypes.Add(friendshipStartProperty); var path3g = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges, null, null, edgePropertyTypes); var path3h = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges, null, null, null, edgePropertyTypes); var path3i = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges, null, null, null, null, p => { object pv = p.GetProperty(countryProperty); return(pv != null && pv.Equals("Sweden")); }); var path3j = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(9465810), edgeTypesToTraverse, null, null, null, null, null, edges, null, null, null, null, null, p => { DateTime?pv = (DateTime?)p.GetProperty(friendshipStartProperty); return(pv != null && pv.Value.CompareTo(DateTime.Now) > 0); }); var path4 = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(2798), edgeTypesToTraverse); var path5 = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(175), edgeTypesToTraverse); var path6 = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(1531), edgeTypesToTraverse); var path7 = someUser.Traverse(4, false, Direction.Out, userType.GetVertex(1537), edgeTypesToTraverse); Console.WriteLine(); // Get all the paths between two user ids var path8 = someUser.Traverse(4, true, Direction.Out, someUser2, edgeTypesToTraverse); path = someUser.Traverse(4, true, Direction.Out, userType.GetVertex(41), edgeTypesToTraverse); // Get the number of unique 2nd level friends a given user has (friends of my friends) var someUsers2ndLevelFriends = (from v in someUserFriends from Edge e in v.GetEdges(friendEdgeType, Direction.Out) select e.Head).Distinct(); Console.WriteLine("unique 2nd level friends a given user has"); int ct = 0; foreach (Vertex v in someUsers2ndLevelFriends) { if (++ct % 100 == 0) { Console.WriteLine("User id: " + v.VertexId); } } Console.WriteLine("Some user has: " + ct + " 2nd level friends"); Console.WriteLine(); // Get the top 10 users with most friends var top10mostFriends = from vertex in userType.GetTopNumberOfEdges(friendEdgeType, 10, Direction.Out) select vertex; Console.WriteLine("top 10 users with most friends"); foreach (Vertex v in top10mostFriends) { long count = v.GetNumberOfEdges(friendEdgeType, Direction.Out); Console.WriteLine("User id: " + v.VertexId + "\t number of friends: " + count); } Console.WriteLine(); session.Commit(); } }
public static MeshX Subdivide(MeshX mesh, Options options) { if (!mesh.helpersInited) { mesh.InitHelpers(); } if (!mesh.normalPerPosition) { mesh.MakeNormalPerPosition(); } MeshX newMesh = new MeshX { name = mesh.name + "/s", content = mesh.content, normalPerPosition = true, }; newMesh.StartBuilding(); CheckForVertexKeys(mesh); var newVertices = new MeshVertices { mesh = newMesh }; var edgeMidPositions = new Dictionary <VertexKey, Vertex>(); // position & normal // reserve indices for new control-points: they keep indices and we need no special keys for them. // later for control-points we set position & normal only: tangent & uv stay the same. for (int pi = 0; pi < mesh.positions.Count; ++pi) { newMesh.AddPosition(default(Vertex)); } for (int vi = 0; vi < mesh.vertexCount; ++vi) { Vertex v = mesh.GetVertex(vi, maskVertex); newMesh.AddVertex(v, addPosition: false); } // add face-points // "for each face, a face point is created which is the average of all the points of the face." foreach (Face f in mesh.IterAllFaces()) { Vertex[] vs = mesh.GetVertices(mesh.GetFaceVertexIndices(f)); Vertex v = mesh.Average(vs); VertexKey keyF = GetFacePointKey(f); newVertices.AddVertices(v, Pair(v, keyF)); } // add edge-points foreach (Edge e in mesh.IterAllEdges()) { EdgeType type = mesh.GetEdgeType(e); if (type == EdgeType.back) { continue; } if (type == EdgeType.boundary) { // "for the edges that are on the border of a hole, the edge point is just the middle of the edge." Vertex midE = mesh.Average( mesh.GetVertices(mesh.GetEdgeVertexIndices(e)) ); VertexKey keyE = GetEdgePointKey(e); edgeMidPositions[keyE] = midE; newVertices.AddVertices(midE, Pair(midE, keyE)); } else if (type == EdgeType.solid) { // "for each edge, an edge point is created which is the average between the center of the edge // and the center of the segment made with the face points of the two adjacent faces." Edge n = mesh.GetNeighbor(e); Vertex midE = mesh.Average( mesh.GetVertices(mesh.GetEdgeVertexIndices(e)) ); VertexKey keyE = GetEdgePointKey(e); edgeMidPositions[keyE] = midE; Vertex v = mesh.Average( new[] { midE, newVertices.GetVertex(GetFacePointKey(e.face)), newVertices.GetVertex(GetFacePointKey(n.face)), }, weights: new[] { 2f, 1f, 1f } ); newVertices.AddVertices(v, Pair(v, keyE)); } else // seam edge { Edge n = mesh.GetNeighbor(e); Vertex midE = mesh.Average( mesh.GetVertices(mesh.GetEdgeVertexIndices(e)) ); Vertex midN = mesh.Average( mesh.GetVertices(mesh.GetEdgeVertexIndices(n)), maskVertex // pos & normal already got in midE ); VertexKey keyE = GetEdgePointKey(e); VertexKey keyN = GetEdgePointKey(n); edgeMidPositions[keyE] = midE; Vertex p = mesh.Average( // pos & normal only new[] { midE, newVertices.GetVertex(GetFacePointKey(e.face), maskPosition), newVertices.GetVertex(GetFacePointKey(n.face), maskPosition), }, maskPosition, new[] { 2f, 1f, 1f } ); newVertices.AddVertices(p, Pair(midE, keyE), Pair(midN, keyN)); } } // move control-points for (int pi = 0; pi < mesh.positions.Count; ++pi) { // count edges var edges = new List <Edge>(); // edges outcoming from the position var boundaries = new List <Edge>(); var front = new List <Edge>(); foreach (int vi in mesh.positionVertices[pi]) { foreach (Edge e in mesh.vertexEdges[vi]) { edges.Add(e); foreach (Edge edge in new[] { e, mesh.GetNextInFace(e, -1) }) { EdgeType type = mesh.GetEdgeType(edge); if (type == EdgeType.boundary) { boundaries.Add(edge); } else if (type != EdgeType.back) { front.Add(edge); } } } } Debug.AssertFormat(boundaries.Count > 0 || (edges.Count == front.Count), "Counting edges error: boundaries: {0}, edges {1}, front: {2}", boundaries.Count, edges.Count, front.Count); Vertex controlPoint; if (boundaries.Count > 0) { bool isCorner = edges.Count == 1; if (options.boundaryInterpolation == Options.BoundaryInterpolation.fixBoundaries || options.boundaryInterpolation == Options.BoundaryInterpolation.fixCorners && isCorner) { controlPoint = mesh.GetPosition(pi); // keep same position } else { // "for the vertex points that are on the border of a hole, the new coordinates are calculated as follows: // 1. in all the edges the point belongs to, only take in account the middles of the edges that are on the border of the hole // 2. calculate the average between these points (on the hole boundary) and the old coordinates (also on the hole boundary)." Vertex[] vs = new Vertex[boundaries.Count + 1]; vs[0] = mesh.GetPosition(pi); for (int e = 0; e < boundaries.Count; ++e) { vs[e + 1] = edgeMidPositions[GetEdgePointKey(boundaries[e])]; } controlPoint = mesh.Average(vs, maskPosition); } } else { // "for each vertex point, its coordinates are updated from (new_coords): // the old coordinates (P), // the average of the face points of the faces the point belongs to (F), // the average of the centers of edges the point belongs to (R), // how many faces a point belongs to (n), then use this formula: // (F + 2R + (n-3)P) / n" // edge-midpoints Vertex[] ms = new Vertex[front.Count]; for (int e = 0; e < front.Count; ++e) { ms[e] = edgeMidPositions[GetEdgePointKey(front[e])]; } Vertex edgeMidAverage = mesh.Average(ms, maskPosition); // face-points Vertex[] fs = new Vertex[edges.Count]; for (int e = 0; e < edges.Count; ++e) { fs[e] = newVertices.GetVertex(GetFacePointKey(edges[e].face), maskPosition); } Vertex faceAverage = mesh.Average(fs, maskPosition); // new control-point controlPoint = mesh.Average( new[] { faceAverage, edgeMidAverage, mesh.GetPosition(pi) }, maskPosition, new[] { 1f, 2f, edges.Count - 3f } ); } // set moved control-point position to reserved index newMesh.SetPosition(pi, controlPoint); } // add 4 new quads per face // eis[i] // fis[i].----.----.fis[i+1] // | | // eis[i-1]. ci. . // | | // .____.____. newMesh.submeshes = new Submesh[mesh.submeshes.Length]; for (int si = 0; si < mesh.submeshes.Length; ++si) { int[][] faces = mesh.submeshes[si].faces; // get new face count int faceCount = 0; foreach (int[] face in faces) { faceCount += face.Length; } newMesh.submeshes[si].faces = new int[faceCount][]; // fill faces int faceIndex = 0; for (int fi = 0; fi < faces.Length; ++fi) { int[] fis = faces[fi]; int edgeCount = fis.Length; // 3 or 4 // Face f = new Face { submesh = si, index = fi }; int ci = newVertices.vertexIndices[GetFacePointKey(f)]; // face-point index // int[] eis = new int[edgeCount]; // edge-point indices for (int i = 0; i < edgeCount; ++i) { Edge e = new Edge { face = f, index = i }; // get neighbor for solid back edges if (mesh.GetEdgeType(e) == EdgeType.back) //!!! here should be some EdgeType.backOfSeam or EdgeType.backOfSolid { Edge n = mesh.GetNeighbor(e); if (mesh.GetEdgeType(n) == EdgeType.solid) { e = n; } } eis[i] = newVertices.vertexIndices[GetEdgePointKey(e)]; } // for (int i = 0; i < edgeCount; ++i) { int[] q = new int[4]; // new faces are always quads int s = edgeCount == 4 ? i : 0; // shift indices (+ i) to keep quad orientation q[(0 + s) % 4] = fis[i]; q[(1 + s) % 4] = eis[i]; q[(2 + s) % 4] = ci; q[(3 + s) % 4] = eis[(i - 1 + edgeCount) % edgeCount]; newMesh.submeshes[si].faces[faceIndex++] = q; } } } newMesh.FinishBuilding(); return(newMesh); }
public override IEdge Retype(IEdge edge, EdgeType newEdgeType) { return Retype((LGSPEdge) edge, newEdgeType); }
public IEdge AddEdge(EdgeType edgeType, INode source, INode target, String elemName) { return(AddEdge(edgeType, (LGSPNode)source, (LGSPNode)target, elemName)); }
static void Main(string[] args) { bool import = args.Length > 0 && args[0].ToLower() == "-import"; bool dirExist = Directory.Exists(s_systemDir); SessionBase.ClearAllCachedObjectsWhenDetectingUpdatedDatabase = false; if (import || !dirExist) { if (dirExist) { Directory.Delete(s_systemDir, true); // remove systemDir from prior runs and all its databases. } Directory.CreateDirectory(s_systemDir); using (SessionNoServer session = new SessionNoServer(s_systemDir)) { DataCache.MaximumMemoryUse = 12000000000; // 12 GB, set this to what fits your case SessionBase.BTreeAddFastTransientBatchSize = 10; // reduces memory usage Vertex[] ratingVertices = new Vertex[10]; session.BeginUpdate(); session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4; Graph g = new Graph(session); // SCHEMA VertexType userType = g.NewVertexType("User"); PropertyType genderType = userType.NewProperty("Gender", DataType.Integer, PropertyKind.Indexed); VertexType ratingType = g.NewVertexType("Rating"); PropertyType ratingValuePropertyType = ratingType.NewProperty("RatingValue", DataType.Integer, PropertyKind.Indexed); EdgeType ratingEdgeType = g.NewEdgeType("UserToRating", true, userType, ratingType); EdgeType ratingOfType = g.NewEdgeType("RatingOf", false, userType, userType); PropertyType ratingEdgePropertyType = ratingOfType.NewProperty("Rating", DataType.Integer, PropertyKind.Indexed); // DATA using (FileStream stream = File.OpenRead(System.IO.Path.Combine(s_inputDataDir, "gender.dat"))) { using (StreamReader file = new System.IO.StreamReader(stream)) { string line; int lineNumber = 0; while ((line = file.ReadLine()) != null) { lineNumber++; string[] fields = line.Split(','); Vertex aUser = userType.NewVertex(); aUser.SetProperty(genderType, (int)fields[1][0] == 'M' ? Gender.Male : fields[1][0] == 'F' ? Gender.Female : Gender.Unknown); } Console.WriteLine("Done importing " + lineNumber + " users"); } } using (FileStream stream = File.OpenRead(System.IO.Path.Combine(s_inputDataDir, "ratings.dat"))) { using (StreamReader file = new System.IO.StreamReader(stream)) { string line; int lineNumber = 0; Vertex rater = null; int raterId; int priorRaterId = -1; while ((line = file.ReadLine()) != null) { lineNumber++; if (lineNumber % 1000000 == 0) { Console.WriteLine("Parsing rating # " + lineNumber); } string[] fields = line.Split(','); raterId = int.Parse(fields[0]); if (raterId != priorRaterId) { rater = userType.GetVertex(raterId); } priorRaterId = raterId; int ratedId = int.Parse(fields[1]); int rating = int.Parse(fields[2]); Vertex ratingVertex = ratingVertices[rating - 1]; if (ratingVertex == null) { ratingVertex = ratingType.NewVertex(); ratingVertex.SetProperty(ratingValuePropertyType, rating); ratingVertices[rating - 1] = ratingVertex; } Vertex rated = userType.GetVertex(ratedId); Edge aRatingOf = ratingOfType.NewEdge(rater, rated); aRatingOf.SetProperty(ratingEdgePropertyType, rating); Edge userRating = ratingEdgeType.NewEdge(rated, ratingVertex); } Console.WriteLine("Done importing " + lineNumber + " ratings"); } } session.Commit(); } } // Query using (SessionNoServer session = new SessionNoServer(s_systemDir)) { session.BeginRead(); Graph g = Graph.Open(session); VertexType userType = g.FindVertexType("User"); PropertyType genderType = userType.FindProperty("Gender"); VertexType ratingType = g.FindVertexType("Rating"); PropertyType ratingValuePropertyType = ratingType.FindProperty("RatingValue"); EdgeType ratingEdgeType = g.FindEdgeType("UserToRating"); EdgeType ratingOfType = g.FindEdgeType("RatingOf"); PropertyType ratingEdgePropertyType = ratingOfType.FindProperty("Rating"); // Complex queries int ct = 0; // Given a user id, and based on the rated profiles, find other users who have rated similarly on the same profiles, and find other profiles to recommend based on what those other users have rated Vertex someUser = userType.GetVertex(1); var similarRatings = (from Edge e in someUser.GetEdges(ratingOfType, Direction.Out) from Edge edge in e.Head.GetEdges(ratingOfType, Direction.Out) where someUser != edge.Head where ((int)e.GetProperty(ratingEdgePropertyType) == (int)edge.GetProperty(ratingEdgePropertyType)) select edge.Tail).Distinct(); var someUserRated = from Edge e in someUser.GetEdges(ratingOfType, Direction.Out) select e.Head; var recommendedProfles = from v in similarRatings from Edge e in v.GetEdges(ratingOfType, Direction.Out) where someUserRated.Contains(e.Head) == false select e.Head; Console.WriteLine("Some user's rated profiles"); ct = 0; foreach (Vertex v in someUserRated) { if (ct++ % 50 == 0) // don't print them all ! { Console.WriteLine("User id: " + v.VertexId); } } Console.WriteLine("Number of some user's rated profiles: " + ct); Console.WriteLine("Given a user id, and based on the rated profiles, find other users who have rated similarly on the same profiles"); ct = 0; foreach (Vertex v in similarRatings) { if (ct++ % 50 == 0) // don't print them all ! { Console.WriteLine("User id: " + v.VertexId); } } Console.WriteLine("Number of matching profiles: " + ct); Console.WriteLine("Given a user id, and based on the rated profiles, find other users who have rated similarly on the same profiles, and find other profiles to recommend based on what those other users have rated"); ct = 0; foreach (Vertex v in recommendedProfles) { if (ct++ % 5000 == 0) // don't print them all ! { Console.WriteLine("User id: " + v.VertexId); } } Console.WriteLine("Number of matching profiles: " + ct); // Get all female users with less than 50 ratings Console.WriteLine(); var females = from u in userType.GetVertices() where ((Gender)u.GetProperty(genderType)) == Gender.Female select u; var femalesLess50Ratings = from f in females where f.GetNumberOfEdges(ratingEdgeType, Direction.Out) < 50 select f; Console.WriteLine("Female users with less than 50 ratings"); ct = 0; foreach (Vertex f in femalesLess50Ratings) { long count = f.GetNumberOfEdges(ratingEdgeType, Direction.Out); if (ct++ % 5000 == 0) // don't print them all ! { Console.WriteLine("User id: " + f.VertexId + "\tnumber of ratings: " + count); } } Console.WriteLine("Number of females with fewer than 50 ratings: " + ct); Console.WriteLine(); // Get all male users with at least one 10 rating Console.WriteLine(); var rated10vertex = (from v in ratingType.GetVertices() where ((int)v.GetProperty(ratingValuePropertyType)) == 10 select v).First(); var rated10 = (from e in rated10vertex.GetEdges(ratingEdgeType, Direction.In) select e.GetVertex(Direction.Out)).Distinct(); var rated10male = from Vertex v in rated10 where ((Gender)v.GetProperty(genderType)) == Gender.Male select v; Console.WriteLine("Males with at least one 10 rating"); ct = 0; foreach (Vertex v in rated10male) { if (ct++ % 5000 == 0) // don't print them all ! { Console.WriteLine("User id: " + v.VertexId); } } Console.WriteLine("Number of males with at least one 10 rating: " + ct); Console.WriteLine(); // Get the first 10 male users who have rated at least 3 of the same profiles as the given user. Console.WriteLine("10 male users who have rated at least 3 of the same profiles as the given user"); var males = from u in userType.GetVertices() where ((Gender)u.GetProperty(genderType)) == Gender.Male select u; var someUserHasRated = from Edge o in someUser.GetEdges(ratingOfType, Direction.Out) select o.Head; var first10withSame3ratedAs = from m in males where (from Edge r in m.GetEdges(ratingOfType, Direction.Out) select r.Head).Intersect(someUserHasRated).ToArray().Length >= 3 select m; ct = 0; foreach (Vertex v in first10withSame3ratedAs) { if (++ct > 10) { break; } Console.WriteLine("User id: " + v.VertexId); } Console.WriteLine(); // Statistical queries // Get the 20 profiles with the most ratings var top20mostRatings = (from v in userType.GetVertices() orderby v.GetNumberOfEdges(ratingEdgeType, Direction.Out) descending select v).Take(20); Console.WriteLine("20 profiles with the most ratings"); ct = 0; foreach (Vertex v in top20mostRatings) { int count = (int)v.GetNumberOfEdges(ratingEdgeType, Direction.Out); Console.WriteLine("User id: " + v.VertexId + "\tnumber of ratings: " + count); } Console.WriteLine(); var ratingsVertexEnum = from v in ratingType.GetVertices() orderby v.GetProperty(ratingValuePropertyType) descending select v; Vertex rating10Vertex = ratingsVertexEnum.First(); // Get the 20 best rated profiles regardless of gender var top = from u in userType.GetVertices() let edgeCt = u.GetNumberOfEdges(ratingEdgeType, rating10Vertex, Direction.Out) orderby edgeCt descending select new { u, edgeCt }; Console.WriteLine("20 best rated profiles regardless of gender"); ct = 0; foreach (var v in top) { if (++ct > 20) { break; } Console.WriteLine("User id: " + v.u.VertexId + "\t10 ratings: " + v.edgeCt); } Console.WriteLine(); // Get the 20 best rated males Console.WriteLine("20 best rated male profiles"); var top20males = from u in userType.GetVertices() where ((Gender)u.GetProperty(genderType)) == Gender.Male let edgeCt = u.GetNumberOfEdges(ratingEdgeType, rating10Vertex, Direction.Out) orderby edgeCt descending select new { u, edgeCt }; ct = 0; foreach (var v in top20males) { if (++ct > 20) { break; } Console.WriteLine("Male User id: " + v.u.VertexId + " \t10 ratings: " + v.edgeCt); } Console.WriteLine(); // Get the 20 best rated females Console.WriteLine("20 best rated female profiles"); var top20females = from u in userType.GetVertices() where ((Gender)u.GetProperty(genderType)) == Gender.Female let edgeCt = u.GetNumberOfEdges(ratingEdgeType, rating10Vertex, Direction.Out) orderby edgeCt descending select new { u, edgeCt }; ct = 0; foreach (var v in top20females) { if (++ct > 20) { break; } Console.WriteLine("Female User id: " + v.u.VertexId + "\t10 ratings: " + v.edgeCt); } session.Commit(); } }
static readonly string systemDir = "QuickStartVelocityGraph"; // appended to SessionBase.BaseDatabasePath static void CreateGraph() { using (SessionNoServer session = new SessionNoServer(systemDir)) { if (Directory.Exists(session.SystemDirectory)) { Directory.Delete(session.SystemDirectory, true); // remove systemDir from prior runs and all its databases. } // Start an update transaction session.BeginUpdate(); Graph g = new Graph(session); session.Persist(g); // Add a node type for the movies, with a unique identifier and two indexed Propertys VertexType movieType = g.NewVertexType("Movie"); PropertyType movieTitleType = g.NewVertexProperty(movieType, "title", DataType.String, PropertyKind.Indexed); PropertyType movieYearType = g.NewVertexProperty(movieType, "year", DataType.Integer, PropertyKind.Indexed); // Add a node type for the actor VertexType actorType = g.NewVertexType("Actor"); PropertyType actorNameType = g.NewVertexProperty(actorType, "name", DataType.String, PropertyKind.Indexed); // Add a directed edge type with a Property for the cast of a movie EdgeType castType = g.NewEdgeType("ACTS_IN", false); PropertyType castCharacterType = g.NewEdgeProperty(castType, "role", DataType.String, PropertyKind.Indexed); // Add some Movies Vertex matrix1 = movieType.NewVertex(); matrix1.SetProperty(movieTitleType, "The Matrix"); matrix1.SetProperty(movieYearType, (int)1999); Vertex matrix2 = movieType.NewVertex(); matrix2.SetProperty(movieTitleType, "The Matrix Reloaded"); matrix2.SetProperty(movieYearType, (int)2003); Vertex matrix3 = movieType.NewVertex(); matrix3.SetProperty(movieTitleType, "The Matrix Revolutions"); matrix3.SetProperty(movieYearType, (int)2003); // Add some Actors Vertex keanu = actorType.NewVertex(); keanu.SetProperty(actorNameType, "Keanu Reeves"); Vertex laurence = actorType.NewVertex(); laurence.SetProperty(actorNameType, "Laurence Fishburne"); Vertex carrieanne = actorType.NewVertex(); carrieanne.SetProperty(actorNameType, "Carrie-Anne Moss"); // Add some edges Edge keanuAsNeo = castType.NewEdge(keanu, matrix1); keanuAsNeo.SetProperty(castCharacterType, "Neo"); keanuAsNeo = castType.NewEdge(keanu, matrix2); keanuAsNeo.SetProperty(castCharacterType, "Neo"); keanuAsNeo = castType.NewEdge(keanu, matrix3); keanuAsNeo.SetProperty(castCharacterType, "Neo"); Edge laurenceAsMorpheus = castType.NewEdge(laurence, matrix1); laurenceAsMorpheus.SetProperty(castCharacterType, "Morpheus"); laurenceAsMorpheus = castType.NewEdge(laurence, matrix2); laurenceAsMorpheus.SetProperty(castCharacterType, "Morpheus"); laurenceAsMorpheus = castType.NewEdge(laurence, matrix3); laurenceAsMorpheus.SetProperty(castCharacterType, "Morpheus"); Edge carrieanneAsTrinity = castType.NewEdge(carrieanne, matrix1); carrieanneAsTrinity.SetProperty(castCharacterType, "Trinity"); carrieanneAsTrinity = castType.NewEdge(carrieanne, matrix2); carrieanneAsTrinity.SetProperty(castCharacterType, "Trinity"); carrieanneAsTrinity = castType.NewEdge(carrieanne, matrix3); carrieanneAsTrinity.SetProperty(castCharacterType, "Trinity"); // Commit the transaction session.Commit(); } }
private bool PipeExists(Coordinate position, EdgeType edge) { return(blueprintBuilder.GetBlock(position).PipesWithOneEdge.Any(blockPipe => blockPipe.Edge == edge)); }
public override Quad GetNeighbor(EdgeType edgeType) { return(GetNeighborFace(edgeType) as Quad); }
public void Create1Vertices(bool vertexIdSetPerVertexType) { DataCache.MaximumMemoryUse = 10000000000; // 10 GB bool dirExist = Directory.Exists(systemDir); try { if (Directory.Exists(systemDir)) { Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases. } Directory.CreateDirectory(systemDir); File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb")); } catch { File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb")); } using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true)) { session.BeginUpdate(); Graph g = new Graph(session, vertexIdSetPerVertexType); session.Persist(g); VertexType userType = g.NewVertexType("User"); VertexType otherType = g.NewVertexType("Other"); PropertyType userNamePropertyType = g.NewVertexProperty(userType, "NAME", DataType.String, PropertyKind.Indexed); VertexType powerUserType = g.NewVertexType("PowerUser", userType); EdgeType userFriendEdgeType = g.NewEdgeType("Friend", true, userType, userType); EdgeType userBestFriendEdgeType = g.NewEdgeType("Best Friend", true, userType, userType, userFriendEdgeType); EdgeType otherEdgeType = g.NewEdgeType("Other", true, userType, userType); PropertyType bestFriendPropertyType = g.NewEdgeProperty(userFriendEdgeType, "START", DataType.DateTime, PropertyKind.Indexed); Vertex kinga = userType.NewVertex(); Vertex robin = userType.NewVertex(); Vertex mats = powerUserType.NewVertex(); Vertex chiran = powerUserType.NewVertex(); Vertex other = otherType.NewVertex(); Edge bestFriend = kinga.AddEdge(userBestFriendEdgeType, robin); Edge otherEdge = kinga.AddEdge(otherEdgeType, robin); DateTime now = DateTime.Now; mats.SetProperty("Address", 1); bestFriend.SetProperty(bestFriendPropertyType, now); kinga.SetProperty(userNamePropertyType, "Kinga"); if (g.VertexIdSetPerType == false) { mats.SetProperty(userNamePropertyType, "Mats"); } else { try { mats.SetProperty(userNamePropertyType, "Mats"); Assert.Fail("Invalid property for VertexType not handled"); } catch (Exception) { } } try { other.SetProperty(userNamePropertyType, "Mats"); Assert.Fail("Invalid property for VertexType not handled"); } catch (Exception) { } try { otherEdge.SetProperty(bestFriendPropertyType, now); Assert.Fail("Invalid property for VertexType not handled"); } catch (Exception) { } Vertex findMats = userNamePropertyType.GetPropertyVertex("Mats", true); var list = userNamePropertyType.GetPropertyVertices("Mats", true).ToList(); //Edge findWhen = bestFriendPropertyType.GetPropertyEdge(now); //var list2 = bestFriendPropertyType.GetPropertyEdges(now); Console.WriteLine(findMats); // session.Commit(); // session.BeginRead(); PropertyType adressProperty = g.FindVertexProperty(powerUserType, "Address"); Vertex find1 = adressProperty.GetPropertyVertex(1, true); session.Abort(); /*session.BeginUpdate(); * g.Unpersist(session); * session.Commit(); * dirExist = Directory.Exists(systemDir); * try * { * if (Directory.Exists(systemDir)) * Directory.Delete(systemDir, true); // remove systemDir from prior runs and all its databases. * Directory.CreateDirectory(systemDir); * File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb")); * } * catch * { * File.Copy(licenseDbFile, Path.Combine(systemDir, "4.odb")); * }*/ } using (SessionNoServer session = new SessionNoServer(systemDir, 5000, false, true)) { session.BeginUpdate(); session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.None; Graph g = new Graph(session, vertexIdSetPerVertexType); session.Persist(g); Graph g2 = new Graph(session); session.Persist(g2); Graph g3 = new Graph(session); session.Persist(g3); UInt32 dbNum = session.DatabaseNumberOf(typeof(Graph)); Graph g4 = (Graph)session.Open(dbNum, 2, 1, true); // g4 == g Graph g5 = (Graph)session.Open(dbNum, 2, 2, true); // g5 == g2 Graph g6 = (Graph)session.Open(dbNum, 2, 3, true); // g6 == g3 for (int i = 4; i < 8; i++) { Graph gt = new Graph(session); session.Persist(gt); } Graph g7 = new Graph(session); Placement place = new Placement(dbNum, 15); session.Persist(place, g7); // SCHEMA VertexType userType = g.NewVertexType("User"); VertexType locationType = g.NewVertexType("Location"); VertexType aVertexType = g.NewVertexType("A"); VertexType bVertexType = g.NewVertexType("B"); VertexType cVertexType = g.NewVertexType("C"); EdgeType uEdge = g.NewEdgeType("unrestricted", true); Vertex aVertex = g.NewVertex(aVertexType); Vertex bVertex = g.NewVertex(bVertexType); Vertex cVertex = g.NewVertex(cVertexType); Edge abEdge = (Edge)aVertex.AddEdge("unrestricted", bVertex); Edge bcEdge = (Edge)aVertex.AddEdge("unrestricted", cVertex); Dictionary <Vertex, HashSet <Edge> > traverse = aVertex.Traverse(uEdge, Direction.Out); abEdge.Remove(); Dictionary <Vertex, HashSet <Edge> > traverse2 = aVertex.Traverse(uEdge, Direction.Out); EdgeType friendEdgeType = g.NewEdgeType("Friend", true, userType, userType); EdgeType userLocationEdgeType = g.NewEdgeType("UserLocation", true, userType, locationType); // DATA Random rand = new Random(5); for (int i = 0; i < numberOfUserVertices / 100; i++) { int vId = rand.Next(numberOfUserVertices); try { if (g.VertexIdSetPerType) { userType.GetVertex(vId); } else { g.GetVertex(vId); } try { userType.NewVertex(vId); Assert.Fail(); } catch (VertexAllreadyExistException) { } } catch (VertexDoesNotExistException) { userType.NewVertex(vId); userType.GetVertex(vId); } } for (int i = 0; i < numberOfUserVertices / 10000; i++) { int vId = rand.Next(numberOfUserVertices); try { Vertex v = userType.GetVertex(vId); v.SetProperty("test", 1); } catch (VertexDoesNotExistException) { } } for (int i = 0; i < numberOfUserVertices / 10000; i++) { int vId = rand.Next(numberOfUserVertices); try { Vertex v = userType.GetVertex(vId); userType.RemoveVertex(v); } catch (VertexDoesNotExistException) { } } foreach (Vertex v in userType.GetVertices().ToArray()) { userType.RemoveVertex(v); } Assert.AreEqual(0, userType.GetVertices().Count()); for (int i = 100000; i < numberOfUserVertices; i++) { userType.NewVertex(); } for (int i = 1; i < 100000; i++) { userType.NewVertex(); } for (int i = 1; i < numberOfLocationVertices; i++) { locationType.NewVertex(); } session.Commit(); session.BeginRead(); foreach (var x in session.AllObjects <BTreeSet <Range <VertexId> > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeSet <EdgeType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeSet <EdgeIdVertexId> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <EdgeId, VelocityDbList <ElementId> > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <string, PropertyType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <string, EdgeType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <string, VertexType> >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <VertexId, BTreeSet <EdgeIdVertexId> > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <VertexType, BTreeMap <VertexId, BTreeSet <EdgeIdVertexId> > > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } foreach (var x in session.AllObjects <BTreeMap <EdgeType, BTreeMap <VertexType, BTreeMap <VertexId, BTreeSet <EdgeIdVertexId> > > > >(false, true)) { Assert.True(x.ToDoBatchAddCount == 0); } session.Commit(); Validate(); } }
private void AddNeighbor(EdgeType edge, Func <QuadFace> face) { _neighborFaces[(int)edge] = face; }
public void AddVertices() { using (var session = new SessionNoServer(@"d:\graphtest2")) { session.DefaultDatabaseLocation().CompressPages = PageInfo.compressionKind.LZ4; DataCache.MaximumMemoryUse = 4000000000; var sw = new Stopwatch(); sw.Start(); //int i = 0; //var dbl = new DatabaseLocation(Dns.GetHostEntry("wordanalysis.cloudapp.net").HostName, @"Z:\DBStore\", 0, // 3, session); //DatabaseLocation bl = session.NewLocation(dbl); //session.Commit(false); // Assert.That(bl!=null); // var db = session.OpenDatabase(15, true); var graph = new Graph(session); session.BeginUpdate(); session.Persist(graph); //define schema Trace.Wri VertexType concept = graph.NewVertexType("Concept"); PropertyType conceptName = concept.NewProperty("ConceptName", DataType.String, PropertyKind.Unique); PropertyType conceptSize = concept.NewProperty("ConceptSize", DataType.Integer, PropertyKind.NotIndexed); PropertyType conceptFrequency = concept.NewProperty("ConceptFrequency", DataType.Integer, PropertyKind.NotIndexed); PropertyType similarity = concept.NewProperty("Similarity", DataType.Double, PropertyKind.NotIndexed); PropertyType vagueness = concept.NewProperty("Vagueness", DataType.Double, PropertyKind.NotIndexed); VertexType instance = graph.NewVertexType("Instance", concept); PropertyType instanceSize = instance.NewProperty("InstanceSize", DataType.Integer, PropertyKind.NotIndexed); PropertyType instanceName = instance.NewProperty("InstanceName", DataType.String, PropertyKind.Unique); PropertyType instanceFrequency = instance.NewProperty("InstanceFrequency", DataType.Integer, PropertyKind.NotIndexed); //VertexType attributes = graph.NewVertexType("Attribute"); ////EdgeType hasAttirbute = attributes.edgattributes.NewHeadToTailEdge(nameScorePair,); //EdgeType cooccursWith = graph.NewEdgeType("CooccursWith", true, instance, instance); //PropertyType coocurrenceFrequency = namedScore.NewProperty("IntScore", DataType.Integer, // PropertyKind.NotIndexed); //VertexType synonym = graph.NewVertexType("Synonym", namedScore); //PropertyType synonymScore = synonym.NewProperty("Score", DataType.Integer, PropertyKind.NotIndexed); //EdgeType hasSynonym = graph.NewEdgeType("HasSynonym", true, synonym, instance); EdgeType isA = graph.NewEdgeType("IsA", true, concept, instance); PropertyType frequency = isA.NewProperty("frequency", DataType.Integer, PropertyKind.NotIndexed); PropertyType popularity = isA.NewProperty("popularity", DataType.Integer, PropertyKind.NotIndexed); PropertyType ZipfSlope = isA.NewProperty("zipf_slope", DataType.Double, PropertyKind.NotIndexed); PropertyType ZipfPearson = isA.NewProperty("zipf_pearson", DataType.Double, PropertyKind.NotIndexed); EdgeType cooccurence = graph.NewEdgeType("Coocurrence", true, concept, concept); //LRVertex vx1 = graph.NewVertex(instance); //vx1.SetProperty("Name", "bla"); //LRVertex vx2 = graph.NewVertex(instance); //vx2.SetProperty("bla", "name"); //LREdge edge = graph.NewEdge(cooccurence, vx1, vx2); Vertex v2 = graph.NewVertex(concept); v2.SetProperty(conceptName, "factor"); Vertex v3 = graph.NewVertex(instance); v3.SetProperty(instanceName, "age"); session.Commit(); } using (var session = new SessionNoServer(@"d:\graphtest2")) { //session.DefaultDatabaseLocation().CompressPages = true; DataCache.MaximumMemoryUse = 4000000000; var sw = new Stopwatch(); sw.Start(); //int i = 0; session.BeginRead(); var graph = Graph.Open(session); //define schema Trace.Wri VertexType[] vertexTypes = graph.FindVertexTypes(); //vertexTypes.Select(x => x.TypeName).PrintDump(); EdgeType[] edgeTypes = graph.FindEdgeTypes(); VertexType concept = vertexTypes.FirstOrDefault(x => x.TypeName == "Concept") ?? graph.NewVertexType("Concept"); PropertyType conceptName = concept.FindProperty("ConceptName"); Assert.IsNotNull(conceptName, "ConceptName"); PropertyType conceptSize = concept.FindProperty("ConceptSize"); Assert.IsNotNull(conceptSize, "ConceptSize"); PropertyType conceptFrequency = concept.FindProperty("ConceptFrequency"); //PropertyType similarity = concept.NewProperty("Similarity", VelocityGraph.DataType.Double, // VelocityGraph.PropertyKind.NotIndexed); PropertyType vagueness = concept.FindProperty("Vagueness");//, DataType.Double,PropertyKind.NotIndexed); VertexType instance = vertexTypes.FirstOrDefault(x => x.TypeName == "Instance"); PropertyType instanceSize = instance.FindProperty("InstanceSize"); PropertyType instanceName = instance.FindProperty("InstanceName"); PropertyType instanceFrequency = instance.FindProperty("InstanceFrequency"); //VertexType attributes = graph.NewVertexType("Attribute"); ////EdgeType hasAttirbute = attributes.edgattributes.NewHeadToTailEdge(nameScorePair,); //EdgeType cooccursWith = graph.NewEdgeType("CooccursWith", true, instance, instance); //PropertyType coocurrenceFrequency = namedScore.NewProperty("IntScore", DataType.Integer, // PropertyKind.NotIndexed); //VertexType synonym = graph.NewVertexType("Synonym", namedScore); //PropertyType synonymScore = synonym.NewProperty("Score", DataType.Integer, PropertyKind.NotIndexed); //EdgeType hasSynonym = graph.NewEdgeType("HasSynonym", true, synonym, instance); EdgeType isA = edgeTypes.FirstOrDefault(x => x.TypeName == "IsA"); PropertyType frequency = isA.FindProperty("frequency"); PropertyType popularity = isA.FindProperty("popularity"); PropertyType ZipfSlope = isA.FindProperty("zipf_slope"); PropertyType ZipfPearson = isA.FindProperty("zipf_pearson"); EdgeType cooccurence = graph.FindEdgeType("Coocurrence"); //LRVertex vx1 = graph.NewVertex(instance); //vx1.SetProperty("Name", "bla"); //LRVertex vx2 = graph.NewVertex(instance); //vx2.SetProperty("bla", "name"); //LREdge edge = graph.NewEdge(cooccurence, vx1, vx2); Assert.IsNotNull(conceptName); Vertex f = graph.FindVertex(conceptName, "factor"); var inst = graph.FindVertex(instanceName, "age"); Assert.IsNotNull(f); Assert.IsNotNull(inst); } //if (instanceVertex == null) }
public QuadFace GetNeighborFace(EdgeType edge) { return(_neighborFaces[(int)edge]()); }
public void AddCircle(EdgeType Type, Coord x, int r) { InBounds(x - r, x + r); DrawEllipse(Type, x - r, x + r); }
//-------------------------------------------------------------------------------------------------- public EdgeSelectionFilter(EdgeType edgeType) { _EdgeType = edgeType; }
public void AddCurve(EdgeType Type, IEnumerable <Coord> Points) { InBounds(Points); DrawCurve(Type, Points.Select(i => (Point)i)); }
/// <summary> /// Create game object for edge /// Terrible code, needs refactored /// </summary> private GameObject InstantiateEdge(string id, string idFriendly, int edgeNumSource, int edgeNumTarget, GameObject source, GameObject target, EdgeType edgeType, bool valueIsKnown, float valueMBtc, float valueMBtcAdditional) { if (source == null || target == null || (source == target)) { Msg.LogWarning("GraphFactory.InstantiateEdge: source or target do not exist, or are identical. Edge not created."); return(null); } // an entirely new link GraphEdgeBrain linkObject = Instantiate(LinkPrefab, new Vector3(0, 0, 0), Quaternion.identity, ParentFolder) as GraphEdgeBrain; linkObject.id = id; linkObject.edgeNumInSource = edgeNumSource; linkObject.edgeNumInTarget = edgeNumTarget; linkObject.name = idFriendly + "--" + edgeNumSource + "--" + edgeNumTarget; // Game Object name linkObject.source = source; linkObject.target = target; //linkObject.SetBitLinkValue(valueIsKnown, valueMBtc); //linkObject.SetBitLinkType(linkType); EdgeType linkType = EdgeType.Input; if (edgeType == EdgeType.Input) { linkType = EdgeType.Input; linkObject.SetBitLinkTypeAndValue_Initial(linkType, valueIsKnown, valueMBtc, edgeType); } else if (edgeType == EdgeType.Output) { linkType = EdgeType.Output; linkObject.SetBitLinkTypeAndValue_Initial(linkType, valueIsKnown, valueMBtcAdditional, edgeType); } else { // TODO Horrible and needs refactored, this is hangover from proof of concept // We are now a mixed link, the method SetBitLinkTypeAndValue_Additional() will handle setting the type to Mixed itself Msg.Log("GraphFactory.InstantiateEdge: Link between source " + source.name + " and target " + target.name + " being PROMOTED TO MIXED"); linkObject.SetBitLinkTypeAndValue_Initial(EdgeType.Input, valueIsKnown, valueMBtc, edgeType); linkObject.SetBitLinkTypeAndValue_Additional(EdgeType.Output, valueIsKnown, valueMBtcAdditional, edgeType); // this counts towards our link counters of course UpdateLinkCountersOnSourceAndTarget(source, target); } linkCount++; // Update link counters UpdateLinkCountersOnSourceAndTarget(source, target); return(linkObject.gameObject); }
public void AddLoop(EdgeType Type, IEnumerable <Coord> Points) { AddCurve(Type, Points); AddLine(Type, Points.First(), Points.Last()); }
/// <summary> /// Instantiates an LGSPEdge object. /// </summary> /// <param name="edgeType">The edge type.</param> /// <param name="sourceNode">The source node.</param> /// <param name="targetNode">The target node.</param> protected LGSPEdge(EdgeType edgeType, LGSPNode sourceNode, LGSPNode targetNode) { lgspType = edgeType; lgspSource = sourceNode; lgspTarget = targetNode; }
//use for cycle detection to assert that the BFS tree has no cycles and is a tree public static List <List <GraphVertex <K, T> > > CycleDetect(List <GraphVertex <K, T> > graph, EdgeType edgeType) { var GraphWithTags = CloneGraph <K, T>(graph); foreach (var vert in GraphWithTags) { // initialize to -1 vert.Index = -1; vert.LowLink = -1; } stronglyConnectedComponents = new List <List <GraphVertex <K, T> > >(); Index = 0; VertStack = new Stack <GraphVertex <K, T> >(); graphcopy = GraphWithTags; foreach (var vert in GraphWithTags) { if (vert.Index < 0) { checkStrongConnect(vert, edgeType); } } return(stronglyConnectedComponents); }
public override LGSPEdge AddEdge(EdgeType edgeType, LGSPNode source, LGSPNode target) { return(AddEdge(edgeType, source, target, null)); }
public override IEdge AddEdge(EdgeType edgeType, INode source, INode target) { return AddEdge(edgeType, (LGSPNode)source, (LGSPNode)target); }
/// <summary> /// Initializes a new instance of the <see cref="TrapezoidalFunction"/> class. /// /// With three points and an edge this shape can be a left fuzzy number (/--) or a right fuzzy number (--\). /// </summary> /// /// <param name="m1">Edge = Left: X value where the degree of membership starts to raise. /// Edge = Right: X value where the function starts, with maximum degree of membership. </param> /// <param name="m2">Edge = Left: X value where the degree of membership reaches the maximum. /// Edge = Right: X value where the degree of membership reaches minimum value. </param> /// <param name="edge">Trapezoid's <see cref="EdgeType"/>.</param> /// /// <remarks> /// <para>Maximum membership value is set to <b>1.0</b> and the minimum is set to <b>0.0</b>.</para> /// </remarks> /// public TrapezoidalFunction(float m1, float m2, EdgeType edge) : this(m1, m2, 1.0f, 0.0f, edge) { }
/// <summary> /// Retypes an edge by replacing it by a new edge of the given type. /// Source and target node as well as all attributes from common super classes are kept. /// </summary> /// <param name="edge">The edge to be retyped.</param> /// <param name="newEdgeType">The new type for the edge.</param> /// <returns>The new edge object representing the retyped edge.</returns> public virtual LGSPEdge Retype(LGSPEdge edge, EdgeType newEdgeType) { LGSPEdge newEdge = (LGSPEdge) newEdgeType.CreateEdgeWithCopyCommons(edge.lgspSource, edge.lgspTarget, edge); RetypingEdge(edge, newEdge); ReplaceEdge(edge, newEdge); return newEdge; }
/// <summary> /// Creates new instance of EdgeData type /// </summary> /// <param name="semantic">Edge semantic</param> /// <param name="flags">Edge flags</param> /// <param name="data">Optional edge data</param> public EdgeData(EdgeType semantic, EdgeFlags flags, object data) { Semantic = semantic; Data = data; Flags = flags; }
public static IGraph SetDefaultEdgeType(this IGraph myIGraph, EdgeType myDefaultEdgeType) { if (myIGraph == null) throw new ArgumentNullException("myIGraph must not be null!"); myIGraph.DefaultEdgeType = myDefaultEdgeType; return myIGraph; }
/// <summary> /// Creates new instance of EdgeData type /// </summary> /// <param name="semantic">Edge semantic</param> /// <param name="data">Optional edge data</param> public EdgeData(EdgeType semantic, object data) { Semantic = semantic; Data = data; Flags = EdgeFlags.None; }