Beispiel #1
0
        public void AddOriginEdge(int startId, int endId, string edge, int id)
        {
            var ew = edges_r[id];

            if (ew != null)
            {
                ew.AddEdges(edge.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            }
            else
            {
                ew = new RelationSide(-id, startId, endId);
                ew.AddEdges(edge.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                edges_r[id] = ew;
            }
        }
Beispiel #2
0
        /// <summary>
        /// 添加一个边
        /// </summary>
        /// <param name="startId">起始实体id</param>
        /// <param name="endId">结束实体id</param>
        /// <param name="edge">边文本,不可为null</param>
        /// <returns></returns>
        public long RegisterEdge(int startId, int endId, string edge)
        {
            var          lid  = ((long)startId << 32) | endId;
            var          rlid = ((long)endId << 32) | startId;
            RelationSide ew;

            if (edgeDict.TryGetValue(lid, out ew) || edgeDict.TryGetValue(rlid, out ew))
            {
                ew.AddEdges(edge.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
            }
            else
            {
                ew = new RelationSide(edgeDict.Count, startId, endId);
                ew.AddEdges(edge.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries));
                edgeDict.Add(lid, ew);
            }
            return(lid);
        }