public NodeObject(int dimension, int validPathCount, NamespaceTypeDefinition thisClass, MethodDefinition constructorToUse, PathElement pathElement, List<int> positionInGraph, int validPathId) : this(dimension, validPathCount, thisClass, constructorToUse, pathElement, positionInGraph) { // add the id of the valid path to the list this.elementOfValidPath.Add(validPathId); }
public NodeObject(int dimension, int validPathCount, NamespaceTypeDefinition thisClass, MethodDefinition constructorToUse, PathElement pathElement, List<int> positionInGraph) { // a list of possible objects in the graph that fulfill the needed attributes like this object this.possibleExchangeObjects = new List<NodeObject>(); // a list of possible classes this object could made of this.possibleClasses = new List<NamespaceTypeDefinition>(); // set the amount of child nodes this node object has this.dimension = dimension; this.nodeObjects = new NodeObject[this.dimension]; // class to use for this node object this.thisClass = thisClass; // constructor to use when a node for the graph is created this.constructorToUse = constructorToUse; // interfaces that this object represents (or not represents) this.pathElements.Add(pathElement); // set the maximum amount of valid paths that this node can be an element of // (in the list elementOfValidPath is the id of the valid path stored this element is a part of) this.validPathCount = validPathCount; this.elementOfValidPath = new List<int>(this.validPathCount); // set the position of this node in the graph this.positionInGraph = positionInGraph; // null every object in the array for (int i = 0; i < this.dimension; i++) { this.nodeObjects[i] = null; } }
// this function fills the rest of the graph with random nodes private void fillNodesRecursively(NodeObject currentNode, List<int> currentPosition, int currentDepth, int maxDepth, List<PossibleNode> allPossibleNodes, ValidGraphPath[] validPaths) { // check if the maximal depth is reached if (currentDepth >= maxDepth) { return; } // fill all missing nodes of the current object with new random nodes for (int idx = 0; idx < currentNode.dimension; idx++) { // copy position list and add path index to the position List<int> tempCurrentPosition = new List<int>(currentPosition); tempCurrentPosition.Add(idx); if (currentNode.nodeObjects[idx] == null) { // get random possible node from list of all possible nodes int randElement = this.prng.Next(allPossibleNodes.Count); PossibleNode possibleNode = allPossibleNodes.ElementAt(randElement); NamespaceTypeDefinition classToUse = possibleNode.givenClass; MethodDefinition nodeConstructor = possibleNode.nodeConstructor; // generate path element from chosen interface PathElement pathElement = new PathElement(); // create new node object currentNode.nodeObjects[idx] = new NodeObject(this.graphDimension, this.graphValidPathCount, classToUse, nodeConstructor, pathElement, tempCurrentPosition); // search through every valid path if the new created filler node has the same attributes as the valid path node // => add it to the list of possible nodes that can be used for an exchange between valid node and filler node for (int validPathId = 0; validPathId < validPaths.Count(); validPathId++) { for (int depth = 0; depth < validPaths[validPathId].pathElements.Count(); depth++) { // check if the used class of the current filler node is in the list of possible classes of the valid path node if (validPaths[validPathId].pathElements.ElementAt(depth).linkGraphObject.possibleClasses.Contains(classToUse)) { // add current filler node to the list of possible exchange nodes if (!validPaths[validPathId].pathElements.ElementAt(depth).linkGraphObject.possibleExchangeObjects.Contains(currentNode.nodeObjects[idx])) { validPaths[validPathId].pathElements.ElementAt(depth).linkGraphObject.possibleExchangeObjects.Add(currentNode.nodeObjects[idx]); } } } } } this.fillNodesRecursively(currentNode.nodeObjects[idx], tempCurrentPosition, currentDepth + 1, maxDepth, allPossibleNodes, validPaths); } }
public NodeObject(int dimension, int validPathCount, NamespaceTypeDefinition thisClass, MethodDefinition constructorToUse, PathElement pathElement, List <int> positionInGraph, int validPathId) : this(dimension, validPathCount, thisClass, constructorToUse, pathElement, positionInGraph) { // add the id of the valid path to the list this.elementOfValidPath.Add(validPathId); }
public NodeObject(int dimension, int validPathCount, NamespaceTypeDefinition thisClass, MethodDefinition constructorToUse, PathElement pathElement, List <int> positionInGraph) { // a list of possible objects in the graph that fulfill the needed attributes like this object this.possibleExchangeObjects = new List <NodeObject>(); // a list of possible classes this object could made of this.possibleClasses = new List <NamespaceTypeDefinition>(); // set the amount of child nodes this node object has this.dimension = dimension; this.nodeObjects = new NodeObject[this.dimension]; // class to use for this node object this.thisClass = thisClass; // constructor to use when a node for the graph is created this.constructorToUse = constructorToUse; // interfaces that this object represents (or not represents) this.pathElements.Add(pathElement); // set the maximum amount of valid paths that this node can be an element of // (in the list elementOfValidPath is the id of the valid path stored this element is a part of) this.validPathCount = validPathCount; this.elementOfValidPath = new List <int>(this.validPathCount); // set the position of this node in the graph this.positionInGraph = positionInGraph; // null every object in the array for (int i = 0; i < this.dimension; i++) { this.nodeObjects[i] = null; } }