public static List<GenericInstantiator.EdgeAggregator> GenerateCorrespondingParts(List<KeyValuePair<Point, Point>> pairs, List<GroundedClause> antecedent, Hypergraph.EdgeAnnotation givenAnnotation) { List<EdgeAggregator> newGrounded = new List<EdgeAggregator>(); // If pairs is populated, we have a Similiarity if (!pairs.Any()) return newGrounded; // Create the similarity between the triangles List<Point> triangleOne = new List<Point>(); List<Point> triangleTwo = new List<Point>(); foreach (KeyValuePair<Point, Point> pair in pairs) { triangleOne.Add(pair.Key); triangleTwo.Add(pair.Value); } GeometricSimilarTriangles simTris = new GeometricSimilarTriangles(new Triangle(triangleOne), new Triangle(triangleTwo)); newGrounded.Add(new EdgeAggregator(antecedent, simTris, givenAnnotation)); // Add all the corresponding parts as new Similar clauses newGrounded.AddRange(SimilarTriangles.GenerateComponents(simTris, triangleOne, triangleTwo)); return newGrounded; }
public PartitionedProblemSpace(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g, QueryFeatureVector query) { graph = g; partitions = new List<ProblemEquivalenceClass>(); this.query = query; totalProblems = 0; }
public InterestingProblemCalculator(Hypergraph<GroundedClause, Hypergraph.EdgeAnnotation> g, List<GroundedClause> f, List<GroundedClause> givens) { this.graph = g; this.figure = f; this.givens = givens; this.goals = new List<GroundedClause>(); // Calculate the givens indices in the hypergraph for this problem this.givenIndices = new List<int>(); foreach (GroundedClause given in givens) { int givenIndex = Utilities.StructuralIndex(graph, given); if (givenIndex == -1) throw new Exception("GIVEN not found in the graph: " + given); givenIndices.Add(givenIndex); } // There are no goals specified this.goalIndices = new List<int>(); // // For intrinsic property-based coverage // COVERAGE_WEIGHTS = new double[NUM_INTRINSIC]; // Sum the factors double sum = 0; foreach (int i in COVERAGE_FACTOR) sum += i; // Divide for weights for (int w = 0; w < NUM_INTRINSIC; w++) { COVERAGE_WEIGHTS[w] = COVERAGE_FACTOR[w] / sum; } }
public TemplateProblemGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g, Pebbler.Pebbler pebbler, ProblemAnalyzer.PathGenerator generator) { graph = g; this.pebbler = pebbler; pathGenerator = generator; }
public static void Go() { using (_sw = new StreamWriter("tarpits cart attempt" + Length + ".txt")) { _sw.AutoFlush = true; System.Console.ForegroundColor = ConsoleColor.White; var tarpitEnumerator = new FastTarpitEnumerator(Length); var count = 0; var tarpitCores = new List <List <string> >(); tarpitEnumerator.GenerateMinimalTarpits(tarpit => { var isClosed = TarpitEnumerator.IsPermutationClosed(tarpit); var core = TarpitEnumerator.RemovePermutationRedundancies(tarpit); core = TarpitEnumerator.ReorderAlphabetByOccurenceRate(core); WriteLine(string.Join(" ", core)); System.Console.ForegroundColor = ConsoleColor.White; count++; tarpitCores.Add(core); }); WriteLine(); Write("found " + count + " tarpits. "); WriteLine("computing transversal hypergraph..."); WriteLine(); var H = new Hypergraph <string>(tarpitCores); var transversals = H.Tr(); var ordered = transversals.E.OrderBy(l => l.Count(ss => ss.Contains('z')) + string.Join("", l.OrderWords())).Select(t => t.OrderWords().ToList()).ToList(); foreach (var t in ordered) { var ss = string.Join(" ", t); WriteLine(ss); } WriteLine(); var chunks = Boxification.SplitMultiway(ordered); foreach (var chunk in chunks) { WriteLine(Boxification.ToMultiChunkString(chunk)); } // var chunks = Boxification.Split(ordered); //foreach (var chunk in chunks) // WriteLine(Boxification.ToChunkString(chunk)); } }
public Pebbler(Hypergraph.Hypergraph<GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> graph, PebblerHypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> pGraph) { this.graph = graph; this.pebblerGraph = pGraph; forwardPebbledEdges = new HyperEdgeMultiMap<Hypergraph.EdgeAnnotation>(pGraph.vertices.Length); backwardPebbledEdges = new HyperEdgeMultiMap<Hypergraph.EdgeAnnotation>(pGraph.vertices.Length); forwardPebbledEdges.SetOriginalHypergraph(graph); backwardPebbledEdges.SetOriginalHypergraph(graph); }
public InterestingProblemCalculator(Hypergraph <GroundedClause, Hypergraph.EdgeAnnotation> g, List <GroundedClause> f, List <GroundedClause> givens, List <GroundedClause> goals) { this.graph = g; this.figure = f; this.givens = givens; this.goals = goals; // Calculate the givens indices in the hypergraph for this problem this.givenIndices = new List <int>(); foreach (GroundedClause given in givens) { int givenIndex = Utilities.StructuralIndex(graph, given); if (givenIndex == -1) { throw new Exception("GIVEN not found in the graph: " + given); } givenIndices.Add(givenIndex); } // Calculate the goal indices in the hypergraph for this problem this.goalIndices = new List <int>(); foreach (GroundedClause goal in goals) { int goalIndex = Utilities.StructuralIndex(graph, goal); if (goalIndex == -1) { throw new Exception("GOAL not found in the graph: " + goal); } goalIndices.Add(goalIndex); } // // For intrinsic property-based coverage // COVERAGE_WEIGHTS = new double[NUM_INTRINSIC]; // Sum the factors double sum = 0; foreach (int i in COVERAGE_FACTOR) { sum += i; } // Divide for weights for (int w = 0; w < NUM_INTRINSIC; w++) { COVERAGE_WEIGHTS[w] = COVERAGE_FACTOR[w] / sum; } }
//Is another graph subgraph public bool IsSubGraph(Hypergraph <T> hypergraph) { int edgesInCommon = hypergraph.Edges.Intersect(hypergraph.Edges).Count(); if (edgesInCommon >= Edges.Count && edgesInCommon <= 0) { return(false); } int verticesInCommon = hypergraph.Vertices.Intersect(hypergraph.Vertices).Count(); if (verticesInCommon >= Vertices.Count && verticesInCommon <= 0) { return(false); } return(true); }
public GradedProblemTree(Problem<Hypergraph.EdgeAnnotation> thatProblem, Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { goal = thatProblem.goal; edges = new Dictionary<List<List<int>>, List<int>>(); this.graph = g; // Note: the edges in this structure are reversed foreach (PebblerHyperEdge<Hypergraph.EdgeAnnotation> edge in thatProblem.edges) { // Construct the list of lists (as nodes are now multi-element lists) List<List<int>> sources = new List<List<int>>(); foreach (int src in edge.sourceNodes) { sources.Add(Utilities.MakeList<int>(src)); } edges.Add(sources, Utilities.MakeList<int>(edge.targetNode)); } }
public static void Main(string[] args) { Hypergraph <string> hypergraph = new Hypergraph <string>(7, 6); hypergraph.Edges[0].Add(hypergraph.Vertices[0]); hypergraph.Edges[0].Add(hypergraph.Vertices[1]); hypergraph.Edges[0].Add(hypergraph.Vertices[2]); hypergraph.Edges[1].Add(hypergraph.Vertices[1]); hypergraph.Edges[1].Add(hypergraph.Vertices[2]); hypergraph.Edges[2].Add(hypergraph.Vertices[2]); hypergraph.Edges[2].Add(hypergraph.Vertices[3]); hypergraph.Edges[2].Add(hypergraph.Vertices[4]); hypergraph.Edges[3].Add(hypergraph.Vertices[5]); hypergraph.Edges[5].Add(hypergraph.Vertices[6]); Console.WriteLine(hypergraph.ToString()); Console.WriteLine(); Console.WriteLine("If we'd like to know edges contains vertex we can use GetEdgesWithVertex operation"); Console.WriteLine("For example, the third vertex contains in edges:"); foreach (Edge <string> edge in hypergraph.GetEdgesWithVertex(hypergraph.Vertices[2])) { Console.Write(hypergraph.Edges.IndexOf(edge) + " "); } Console.WriteLine(); Console.WriteLine(); Console.WriteLine("Now, edge 4 is empty and after Trim operation in should be terminated"); hypergraph.Trim(); Console.WriteLine(hypergraph.ToString()); }
//Copy constrictor public Hypergraph(Hypergraph <T> hypergraph) { Vertices = new List <Vertex <T> >(hypergraph.Vertices); Edges = new List <Edge <T> >(hypergraph.Edges); }
// // Adds the specified edge to the graph; if the List does not exist, we create it and add the Edge // public void AddEdge(int u, int v, int weight, bool rev, Hypergraph.HyperEdge hyperedge) { // create the list, if needed if (vertexList[u] == null) { vertexList[u] = new List<Edge>(); } // Do not allow duplicate edges Utilities.AddUnique<Edge>(vertexList[u], new Edge(u, v, weight, rev, hyperedge)); }
public Edge(int f, int t, int w, bool rev, Hypergraph.HyperEdge he) { from = f; to = t; weight = w; reversed = rev; hyperedge = he; }
public PathGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> hypergraph) { this.graph = hypergraph; GRAPH_DIAMETER = hypergraph.vertices.Count; }
public Instantiator() { graph = new Hypergraph <GroundedClause, Hypergraph.EdgeAnnotation>(); }
public EdgeAggregator(List<ConcreteAST.GroundedClause> antes, ConcreteAST.GroundedClause c, Hypergraph.EdgeAnnotation ann) { antecedent = new List<ConcreteAST.GroundedClause>(antes); consequent = c; annotation = ann; }
public HypergraphWrapper(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; hintGenerator = new HintGenerator.HintGenerator(g); }
public Instantiator() { graph = new Hypergraph<GroundedClause, Hypergraph.EdgeAnnotation>(); }
public HintGenerator(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; }
public ProblemEquivalenceClass(Hypergraph.Hypergraph<ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; elements = new List<Problem<Hypergraph.EdgeAnnotation>>(); }
public void SetOriginalHypergraph(Hypergraph.Hypergraph<GeometryTutorLib.ConcreteAST.GroundedClause, Hypergraph.EdgeAnnotation> g) { graph = g; forwardPebbledEdges.SetOriginalHypergraph(g); backwardPebbledEdges.SetOriginalHypergraph(g); }