public Dictionary <uint, graphNode> formUndirectedGraph()
        {
            var retGraph     = new Dictionary <uint, graphNode>();
            var numTriangles = getNumIndices() / 3;

            for (var i = 0; i < numTriangles; i++)
            {
                uint[] triIndices = new uint[3];
                triIndices[0] = indices[i * 3];
                triIndices[1] = indices[i * 3 + 1];
                triIndices[2] = indices[i * 3 + 2];

                foreach (var triIndex in triIndices)
                {
                    if (retGraph.ContainsKey(triIndex) == false)
                    {
                        retGraph[triIndex] = new graphNode((int)triIndex);
                    }

                    var curGraphNode = retGraph[triIndex];
                    for (var j = 0; j < triIndices.Length; j++)
                    {
                        var cmpIndex = triIndices[j];
                        if (cmpIndex != triIndex)
                        {
                            curGraphNode.neighbours.Add((int)cmpIndex);
                        }
                    }
                }
            }

            return(retGraph);
        }
        public commandTreeDescription(String __name, graphNode __parent)
        {
            parent = __parent;
            name   = __name;

            commandTreeDescription __p = parent as commandTreeDescription;

            __p.Add(this, __name);
        }
Example #3
0
 public node_view(graph_view _graph_view)
 {
     this._graph_view = _graph_view;
     _graph_view.TopList.Add(this);
     _grNode = new graphNode(this);
     _grNode.txtWeight_node.Text = "5";
     _grNode.lblId_node.Content  = _grNode.txtId_node.Text = (_graph_view.maxTopID() + 1).ToString();
     id     = int.Parse(_grNode.txtId_node.Text);
     weight = int.Parse(_grNode.txtWeight_node.Text);
     _graph_view.GRCanvas.Children.Add(_grNode);
     pointPositionChange += _graph_view.OnPointPositionChanged;
     IsValid              = false;
 }
Example #4
0
 public node_view(graph_view _graph_view)
 {
     this._graph_view = _graph_view;
     _graph_view.TopList.Add(this);
     _grNode = new graphNode(this);
     _grNode.txtWeight_node.Text = "5";
     _grNode.lblId_node.Content = _grNode.txtId_node.Text = (_graph_view.maxTopID() + 1).ToString();
     id = int.Parse(_grNode.txtId_node.Text);
     weight = int.Parse(_grNode.txtWeight_node.Text);
     _graph_view.GRCanvas.Children.Add(_grNode);
     pointPositionChange += _graph_view.OnPointPositionChanged;
     IsValid = false;
 }
Example #5
0
        /// <summary>
        /// Detects subtree matches in the filesystem
        /// </summary>
        /// <param name="filePatterns">The file patterns.</param>
        /// <param name="min">The minimum.</param>
        /// <returns></returns>
        public graphNodeSetCollection findNodeTreeMatch(List <String> filePatterns, Int32 min = -1)
        {
            List <String> paths = new List <string>();

            paths = findFiles(filePatterns, SearchOption.AllDirectories);

            graphNode output = paths.BuildGraphFromPaths <graphNode>();

            List <IObjectWithPathAndChildren> leafList = output.getAllLeafs();

            List <graphNode> leafNodes = new List <graphNode>();

            foreach (var leaf in leafList)
            {
                if (leaf != null)
                {
                    leafNodes.Add((graphNode)leaf);
                }
            }

            return(leafNodes.GetFirstNodeWithLeafs <graphNode>(filePatterns, min));
        }
Example #6
0
 public void addNode()
 {
     if (Circle.Count == 0)
     {
         var cir = new graphNode();
         int X   = r.Next(5, 755);
         int Y   = r.Next(5, 435);
         cir.circle    = CreateCircle(nodeRadius);
         cir.circlePos = new Vector2(X, Y);
         cir.circleCol = Color.Red;
         cir.connector = 1000;
         Circle.Add(cir);
     }
     else if (Circle.Count == 1)
     {
         var cir = new graphNode();
         int X   = r.Next(5, 755);
         int Y   = r.Next(5, 435);
         cir.circle    = CreateCircle(nodeRadius);
         cir.circlePos = new Vector2(X, Y);
         cir.circleCol = Color.Red;
         cir.connector = 0;
         Circle.Add(cir);
     }
     else
     {
         var cir      = new graphNode();
         int X        = r.Next(5, 755);
         int Y        = r.Next(5, 435);
         int nodeConn = r.Next(0, Circle.Count);
         cir.circle    = CreateCircle(nodeRadius);
         cir.circlePos = new Vector2(X, Y);
         cir.circleCol = Color.Red;
         cir.connector = nodeConn;
         Circle.Add(cir);
     }
 }
Example #7
0
 public static DirectedGraph ConvertToDGML(this graphNode graph, Int32 DepthLimit = 300)
 {
     return(DefaultGraphToDGMLConverterInstance.Convert(graph, DepthLimit));
 }
Example #8
0
 /// <summary>
 /// Converts to free graph -- from the specified node to its leafs (downwards)
 /// </summary>
 /// <param name="graph">The graph.</param>
 /// <param name="DepthLimit">The depth limit.</param>
 /// <returns></returns>
 public static freeGraph ConvertToFreeGraph(this graphNode graph, Int32 DepthLimit = 300)
 {
     return(GraphConversionTools.BasicConverterInstance.Convert(graph, DepthLimit));
 }
Example #9
0
    public List <int> getPath(graphNode sourceNode, graphNode targetNode)
    {
        minPriQue.Clear();
        traversedList.Clear();
        dontReturnList.Clear();

        bool found     = false;
        int  exitCount = 1;



        int placement = 0;

        foreach (graphNode indic in nodeList)
        {
            nodeList[placement].GetComponent <graphNode>().HCost = Vector3.Distance(nodeList[placement].GetComponent <graphNode>().transform.position, targetNode.GetComponent <graphNode>().transform.position); // assings h cost
            placement += 1;
        }



        placement = 0;
        foreach (graphEdge edge in sourceNode.adjacencyList)
        {
            minPriQue.Add(sourceNode.adjacencyList[placement]);
            placement += 1;
        }



        while (found == false)
        {
            if (exitCount > 500)
            {
                Debug.Log("exit error, was in loop");



                if (debugMode == true)                                                                                               //  visualising path, only used for testing / prrof of work
                {
                    Debug.DrawLine(sourceNode.transform.position, nodeList[traversedList[0]].transform.position, Color.green, 5.5f); //
                    for (int i = traversedList.Count; i > 1; i--)
                    {
                        Debug.DrawLine(nodeList[traversedList[i - 1]].transform.position, nodeList[traversedList[i - 2]].transform.position, Color.magenta, 5.5f);
                    }
                }



                dontReturnList.Clear();

                found = true;
                return(traversedList);
            }


            float bestFCOST = 999;

            placement = 0;
            foreach (graphEdge edge in minPriQue)
            {
                //if ((minPriQue[placement].GCost) + (   nodeList[minPriQue[placement].to].HCost * 1.5f ) < bestFCOST)
                if (nodeList[minPriQue[placement].to].HCost < bestFCOST)
                {
                    if (dontReturnList.Contains(edge.to))
                    {
                        // dont add as target node if already visited. to avoid backtrack
                    }
                    else
                    {
                        bestFCOST       = nodeList[minPriQue[placement].to].HCost;
                        currentPathNode = nodeList[minPriQue[placement].to];
                    }
                }



                placement += 1;
            }


            traversedList.Add(currentPathNode.id);
            dontReturnList.Add(currentPathNode.id);

            placement = 0;
            foreach (Vector3 vert in verticies)
            {
                if (vert == currentPathNode.transform.position)
                {
                    dontReturnList.Add(nodeList[placement].id);
                }
                placement += 1;
            }



            foreach (graphEdge edge in currentPathNode.adjacencyList)
            {
                if (nodeList[edge.to].transform.position == currentPathNode.transform.position)
                {
                    dontReturnList.Add(nodeList[edge.to].id);
                }
            }



            placement = 0;
            foreach (graphArea area in currentPathNode.areaList)
            {
                foreach (graphArea targAreas in targetNode.areaList)
                {
                    if (area.area == targAreas.area)
                    {
                        found = true;
                        Debug.Log("FOUND ! Area");



                        //Debug.DrawLine(sourceNode.transform.position, nodeList[traversedList[0]].transform.position, Color.green, 5.5f);  //

                        if (debugMode == true)   //  visualising path, only used for testing / prrof of work
                        {
                            for (int i = traversedList.Count; i > 1; i--)
                            {
                                Debug.DrawLine(nodeList[traversedList[i - 1]].transform.position, nodeList[traversedList[i - 2]].transform.position, Color.magenta, 50.5f);
                            }
                        }



                        return(traversedList);
                    }
                }

                if (currentPathNode.id == targetNode.id)
                {
                    found = true;

                    return(traversedList);
                }



                placement = 0;


                if (found == false)
                {
                    foreach (graphEdge edge in currentPathNode.adjacencyList)
                    {
                        minPriQue.Add(currentPathNode.adjacencyList[placement]);
                        placement += 1;
                    }
                }



                exitCount += 1;
            }
        }

        return(traversedList);
    }