示例#1
0
 // this is currently too general. It should rather work on a partition.
 /// <summary>
 /// A node n is order-independent in g if all nodes in 
 /// its neighborhood are in singleton buckets
 /// </summary>
 bool IsOrderIndependent(Node n, RootedLabeledDirectedGraph g)
 {
     if (orderIndependent.ContainsKey(n))
         return orderIndependent[n];
     VertexData nData = g.vertexRecords[n];
     foreach (Pair<CompoundTerm, Node> edge in nData.incomingEdges)
         if (bucketOf[g.LabelOf(edge.Second)].Size > 1)
         {
             orderIndependent.Add(n, false);
             return false;
         }
     foreach (Pair<CompoundTerm, Node> edge in nData.orderedOutgoingEdges)
         if (bucketOf[g.LabelOf(edge.Second)].Size > 1)
         {
             orderIndependent.Add(n, false);
             return false;
         }
     foreach (Pair<CompoundTerm, Set<Node>> edge in nData.unorderedOutgoingEdges)
         foreach (Node x1 in edge.Second)
             if (bucketOf[g.LabelOf(x1)].Size > 1)
             {
                 orderIndependent.Add(n, false);
                 return false;
             }
     orderIndependent.Add(n, true);
     return true;
 }
示例#2
0
            //private class NodePartition : SortedList<Node, object>
            //{
            //    internal bool independent;
            //    internal NodePartition(Node x, bool independent)
            //        : base()
            //    {
            //        base.Add(x, null);
            //        this.independent = independent;
            //    }
            //    internal void AddNode(Node x)
            //    {
            //        base.Add(x, null);
            //    }
            //    internal IList<Node> Nodes
            //    {
            //        get
            //        {
            //            return base.Keys;
            //        }
            //    }
            //}
            /// <summary>
            /// Partition the set of neighbors of all outgoing unordered edges of a node x in g.
            /// Returns all the partitions indexed by the pair (E,L) where
            /// E is an edge label and L is the label of the neighbor.
            /// 
            /// A partition is marked order-independent if some node in that partition is 
            /// order-independent, which implies that all nodes in the same partition must be 
            /// order-independent as well (this is a property implied by the node labeling/hashing algorithm).
            /// </summary>
            /// <param name="g">given graph</param>
            /// <param name="node">given node in g</param> 
            /// <param name="edgeLabel">given edge label</param>
            static Map<Pair<IComparable, bool>, Set<Node>> GetPartitions(RootedLabeledDirectedGraph g, Node node, CompoundTerm edgeLabel)
            {
                Map<Pair<IComparable,bool>, Set<Node>> partitions =
                    Map<Pair<IComparable,bool>, Set<Node>>.EmptyMap;
                VertexData xData1 = g.vertexRecords[node]; // xData is already in context.

                foreach (Node x1 in xData1.unorderedOutgoingEdges[edgeLabel])
                {
                    Pair<IComparable, bool> key = new Pair<IComparable, bool>(g.LabelOf(x1), true);//IsOrderIndependent(x1, g));
                    Set<Node> nodePartition;
                    if (partitions.TryGetValue(key, out nodePartition))
                        partitions=partitions.Override(key,nodePartition.Add(x1));
                    else
                        partitions=partitions.Add(key, new Set<Node>(x1));

                }
                return partitions;
            }