public void ComputeShortestPath_SimpleGraphNotReachable_Throws()
        {
            var g = CreateGraph(5, false, (0, 1, 1), (1, 2, 1), (2, 3, 1), (3, 4, 1), (0, 4, 5));
            var a = new DijkstraShortestPathAlgorithm <DirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());

            Assert.That(() => a.ComputeShortestPath(new VertexIdx(2), new VertexIdx(0), out _), Throws.ArgumentException);
        }
Пример #2
0
        public void ComputeMinimumSpanningTree_SimpleGraph_IsCorrect()
        {
            var g            = CreateGraph(3, (0, 1, 1), (1, 2, 2));
            var a            = new PrimMinimumSpanningTreeAlgorithm <UndirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());
            var spanningTree = a.ComputeMinimumSpanningTree(new VertexIdx(0));

            Assert.That(spanningTree.ToArray(), Is.EquivalentTo(Edges(0, 1)));
        }
        public void ComputeShortestPath_WikipediaExample_ReturnsCorrectDistance()
        {
            var g = CreateGraph(6, true, (0, 1, 7), (0, 2, 9), (0, 5, 15), (1, 2, 10), (1, 3, 15), (2, 3, 11), (2, 5, 2), (3, 4, 6), (4, 5, 9));
            var a = new DijkstraShortestPathAlgorithm <DirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());

            a.ComputeShortestPath(new VertexIdx(0), new VertexIdx(4), out var shortestDistance);
            Assert.That(shortestDistance, Is.EqualTo(20));
        }
        public void ComputeShortestPath_SimpleGraph_IsCorrectPath(int start, int target, params int[] edges)
        {
            var g    = CreateGraph(5, false, (0, 1, 1), (1, 2, 1), (2, 3, 1), (3, 4, 1), (0, 4, 5));
            var a    = new DijkstraShortestPathAlgorithm <DirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());
            var path = a.ComputeShortestPath(new VertexIdx(start), new VertexIdx(target), out _);

            Assert.That(path.ToArray(), Is.EqualTo(edges.Select(x => new EdgeIdx(x))));
        }
        public void ComputeShortestPath_SimpleGraph_ReturnsCorrectDistance(int start, int target, int distance)
        {
            var g = CreateGraph(5, false, (0, 1, 1), (1, 2, 1), (2, 3, 1), (3, 4, 1), (0, 4, 5));
            var a = new DijkstraShortestPathAlgorithm <DirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());

            a.ComputeShortestPath(new VertexIdx(start), new VertexIdx(target), out var shortestDistance);
            Assert.That(shortestDistance, Is.EqualTo(distance));
        }
Пример #6
0
        public void ComputeMinimumSpanningTree_WikipediaExample_IsCorrect()
        {
            var g            = CreateGraph(6, (0, 1, 1), (0, 3, 4), (0, 4, 3), (1, 3, 4), (1, 4, 2), (2, 4, 4), (2, 5, 5), (3, 4, 4), (4, 5, 7));
            var a            = new PrimMinimumSpanningTreeAlgorithm <UndirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());
            var spanningTree = a.ComputeMinimumSpanningTree(new VertexIdx(0));

            Assert.That(spanningTree.Length, Is.EqualTo(5));
            Assert.That(spanningTree.ToArray().Sum(e => g.GetEdgeTag(e)), Is.EqualTo(16));
        }
        public void ComputeMaximumFlow_WikipediaExample_ReturnsCorrectFlow()
        {
            var g           = CreateGraph(7, (0, 3, 3), (0, 1, 3), (1, 2, 4), (2, 0, 3), (2, 3, 1), (2, 4, 2), (3, 4, 2), (3, 5, 6), (4, 1, 1), (4, 6, 1), (5, 6, 9));
            var a           = new EdmondsKarpMaximumFlowAlgorithm <DirectedGraph <Empty, int>, VertexIdx, EdgeIdx, int>(g, new IntCalculator());
            var maximumFlow = a.ComputeMaximumFlow(new VertexIdx(0), new VertexIdx(6), out var sourcePartition);

            Assert.That(maximumFlow, Is.EqualTo(5));
            Assert.That(sourcePartition, Is.EquivalentTo(Vertices(0, 1, 2, 4)));
        }
        public void ComputeStronglyConnectedComponents_SimpleGraph_SecondRunReturnsNoComponents()
        {
            var g = CreateGraph(5, false, (0, 1), (1, 2), (2, 3), (3, 4), (0, 4));
            var a = new TarjanStronglyConnectedComponentsAlgorithm <DirectedGraph <Empty, Empty>, VertexIdx, EdgeIdx>(g);

            a.ComputeStronglyConnectedComponents(new VertexIdx(0));
            var components = a.ComputeStronglyConnectedComponents(new VertexIdx(0));

            Assert.That(components.Length, Is.Zero);
        }
        public void ComputeStronglyConnectedComponents_SimpleGraph_IsCorrect()
        {
            var g          = CreateGraph(5, false, (0, 1), (1, 2), (2, 3), (3, 4), (0, 4));
            var a          = new TarjanStronglyConnectedComponentsAlgorithm <DirectedGraph <Empty, Empty>, VertexIdx, EdgeIdx>(g);
            var components = a.ComputeStronglyConnectedComponents(new VertexIdx(0));

            Assert.That(components.Length, Is.EqualTo(5));
            Assert.That(components[0].ToArray(), Is.EqualTo(new[] { new VertexIdx(4) }));
            Assert.That(components[1].ToArray(), Is.EqualTo(new[] { new VertexIdx(3) }));
            Assert.That(components[2].ToArray(), Is.EqualTo(new[] { new VertexIdx(2) }));
            Assert.That(components[3].ToArray(), Is.EqualTo(new[] { new VertexIdx(1) }));
            Assert.That(components[4].ToArray(), Is.EqualTo(new[] { new VertexIdx(0) }));
        }
        public void ComputeStronglyConnectedComponents_WikipediaExample_IsCorrect()
        {
            var g = CreateGraph(8, false, (0, 4), (1, 0), (2, 1), (2, 3), (3, 2), (4, 1), (5, 1), (5, 4), (5, 6),
                                (6, 2), (6, 5), (7, 3), (7, 6), (7, 7));
            var a          = new TarjanStronglyConnectedComponentsAlgorithm <DirectedGraph <Empty, Empty>, VertexIdx, EdgeIdx>(g);
            var components = a.ComputeStronglyConnectedComponents(new VertexIdx(7));

            Assert.That(components.Length, Is.EqualTo(4));
            Assert.That(components[0].ToArray(), Is.EquivalentTo(Vertices(0, 1, 4)));
            Assert.That(components[1].ToArray(), Is.EquivalentTo(Vertices(2, 3)));
            Assert.That(components[2].ToArray(), Is.EquivalentTo(Vertices(5, 6)));
            Assert.That(components[3].ToArray(), Is.EquivalentTo(Vertices(7)));
        }
Пример #11
0
        /*public static QuickGraph.AdjacencyGraph<int, QuickGraph.Edge<int>> GraphToAdjacencyQuickGraph(Graph g)
         * {
         *  var graph = new QuickGraph.AdjacencyGraph<int, QuickGraph.Edge<int>>();
         *  QuickGraph.Edge<int>[] edges = new QuickGraph.Edge<int>[g.order];
         *  for (int i = 0; i < g.order; i++)
         *  {
         *      for (int j = i + 1; j < g.order; j++)
         *      {
         *          if (g.adjacencyMatrix[i, j] == 1) graph.AddEdge(new QuickGraph.Edge<int>(i, j));
         *      }
         *  }
         *  EdmondsKarpMaximumFlowAlgorithm<int, QuickGraph.Edge<int>>()
         *
         *  return graph;
         * }*/



        public static CreateGraph G6toQuickGraph(string g6)
        {
            int[,] adjMatrix = Graph6toAdjMatrix(g6);
            var graph = new CreateGraph();
            int order = adjMatrix.GetLength(0);

            //Create vertices
            for (int i = 0; i < order; i++)
            {
                var vertex = new DataVertex("" + i);
                graph.AddVertex(vertex);
            }

            var vlist = graph.Vertices.ToList();

            //Create edges of graph g

            for (int i = 0; i < order; i++)
            {
                for (int j = i + 1; j < order; j++)
                {
                    if (adjMatrix[i, j] == 1)
                    {
                        var edge  = new DataEdge(vlist[i], vlist[j]);
                        var edge1 = new DataEdge(vlist[j], vlist[i]);
                        graph.AddEdge(edge);
                        graph.AddEdge(edge1);
                    }
                }
            }
            return(graph);
        }
        public void ComputeStronglyConnectedComponents_SimpleGraph_CanRunPartially()
        {
            var g          = CreateGraph(5, false, (0, 1), (1, 2), (2, 3), (3, 4), (0, 4));
            var a          = new TarjanStronglyConnectedComponentsAlgorithm <DirectedGraph <Empty, Empty>, VertexIdx, EdgeIdx>(g);
            var components = a.ComputeStronglyConnectedComponents(new VertexIdx(2));

            Assert.That(components.Length, Is.EqualTo(3));
            Assert.That(components[0].ToArray(), Is.EqualTo(Vertices(4)));
            Assert.That(components[1].ToArray(), Is.EqualTo(Vertices(3)));
            Assert.That(components[2].ToArray(), Is.EqualTo(Vertices(2)));

            components = a.ComputeStronglyConnectedComponents(new VertexIdx(0));

            Assert.That(components.Length, Is.EqualTo(2));
            Assert.That(components[0].ToArray(), Is.EqualTo(Vertices(1)));
            Assert.That(components[1].ToArray(), Is.EqualTo(Vertices(0)));
        }
Пример #13
0
    // Start is called before the first frame update
    void Start()
    {
        CreateGraph CG = FindObjectOfType <CreateGraph>();

        player.SetInitialNode(CG.Graph[101]); // node 14
        light.SetBase(CG.Graph[78 + 5]);
        dark.SetBase(CG.Graph[10]);
    }
Пример #14
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        CreateGraph cg = (CreateGraph)target;

        if (GUILayout.Button("Generate Graph"))
        {
            cg.Generate();
        }

        if (GUILayout.Button("Clear Graph"))
        {
            cg.Clear();
        }
    }
Пример #15
0
    public IEnumerator TravelTo(WM_Node endNode)
    {
        List <WM_Node> path = new List <WM_Node>();

        path = CreateGraph.PathToNode(currentNode, endNode);
        //Debug.Log(this.name  + " path count : " + path.Count);

        for (int i = 0; i < path.Count; i++)
        {
            //Debug.Log(this.name + " going through " + path[i].name);
        }

        for (int i = 0; i < path.Count; i++)
        {
            yield return(StartCoroutine(MovePartyTo(path[i])));
        }
        //Debug.Log("arrived to destination");
        yield return(new WaitForEndOfFrame());

        yield return(null);
    }
Пример #16
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Faction F = (Faction)target;

        // SETBASE
        CreateGraph CG   = FindObjectOfType <CreateGraph>();
        int         size = CG.Graph.Count;

        string[] options = new string[size];
        if (FBase == null) // if new graph was created then lost previous base link, so give a new base
        {
            FBase      = CG.Graph[0];
            FBaseIndex = 0;
        }
        for (int i = 0; i < size; i++)
        {
            if (FBase.name == CG.Graph[i].name)
            {
                FBaseIndex = i;                                 // so that the popup shows the current base
            }
            options[i] = CG.Graph[i].name;
        }
        FBaseIndex = EditorGUILayout.Popup("Select Faction Base", FBaseIndex, options);
        FBase      = CG.Graph[FBaseIndex];
        if (GUILayout.Button("Set Base"))
        {
            F.SetBase(FBase); // force the base initialisation if new graph
        }
        // END SETBASE


        numUnits = EditorGUILayout.IntField("Number of units in sqad", numUnits);
        EditorGUILayout.LabelField("Select function for the new unit");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Roam") && numUnits >= 1)
        {
            F.SpawnNewUnits(numUnits, F.roamingUnits);
        }
        GUILayout.EndHorizontal();

        // adding enemies
        Faction[] factions     = FindObjectsOfType <Faction>();
        string[]  factionsName = new string[factions.Length];
        int       fnIndex      = -1;

        for (int i = 0; i < factions.Length; i++)
        {
            if (factions[i] == F)
            {
                continue;
            }
            factionsName[i] = factions[i].name;
        }
        fnIndex = EditorGUILayout.Popup("Select Enemy", fnIndex, factionsName);
        if (fnIndex != -1)
        {
            F.enemy.Add(factions[fnIndex]);
        }
    }
Пример #17
0
 private void Awake()
 {
     CG = FindObjectOfType <CreateGraph>();
 }
Пример #18
0
        public static void Main(string[] args)
        {
            bool fragment = false;

            #region Handle Input

            List <string> arguments = new List <string>(args);

            // First, look for flags
            List <string> flags = arguments.FindAll(delegate(string s) { return(s[0] == '-'); });
            foreach (string f in flags)
            {
                arguments.Remove(f);
            }
            foreach (string flag in flags)
            {
                switch (flag[1])
                {
                case 'F':
                    fragment = true;
                    break;
                }
            }

            if (arguments.Count != 2)
            {
                printUsageAndExit();
            }
            if (!Directory.Exists(arguments[1]))
            {
                Console.WriteLine("Directory {0} not found!", arguments[1]);
                Console.WriteLine();
                printUsageAndExit();
            }
            if (!File.Exists(arguments[0]))
            {
                Console.WriteLine("LabelMapper Description File {0} not found!{1}", arguments[0], Environment.NewLine);
                printUsageAndExit();
            }
            string lmFile = arguments[0];

            List <string> files = new List <string>(Directory.GetFiles(arguments[1], "*.xml", SearchOption.AllDirectories));
            if (files.Count == 0)
            {
                Console.WriteLine("No XML files found in {0}!{1}", arguments[1], Environment.NewLine);
                printUsageAndExit();
            }
            string outputDirectory;
            if (fragment)
            {
                outputDirectory = arguments[1] + @"\DTF_Fragmented";
                Console.WriteLine("Will auto-fragment all sketches");
            }
            else
            {
                outputDirectory = arguments[1] + @"\DTF_Unfragmented";
                Console.WriteLine("Will not auto-fragment any sketches");
            }
            if (!Directory.Exists(outputDirectory))
            {
                Console.WriteLine("Creating output directory {0}", outputDirectory);
                Directory.CreateDirectory(outputDirectory);
            }
            else
            {
                Console.WriteLine("Using existing output directory {0}", outputDirectory);
            }

            #endregion

            string names_file = outputDirectory + "\\features.names";

            LabelMapper.LabelMapper lm = new LabelMapper.LabelMapper(lmFile);
            DTF all = new DTF(lm.translatedClasses);
            addFeaturesToDTF(ref all);
            all.WriteNamesFile(names_file);

            Console.WriteLine("Beginning DTF calculations at {0}", DateTime.Now.ToShortTimeString());

            foreach (string filename in files)
            {
                Console.Write(".");
                if (!File.Exists(filename))
                {
                    throw new FileNotFoundException("File {0} not found", filename);
                }
                Sketch.Sketch sk;
                try
                {
                    ConverterXML.ReadXML reader = new ConverterXML.ReadXML(filename);
                    sk = reader.Sketch;
                }
                catch (System.Xml.XmlException e)
                {
                    Console.WriteLine("Error reading file {0} with ConverterXML. Exception Text: {1}", filename, e.Message);
                    continue;
                }
                if (fragment)
                {
                    Fragmenter.Fragment.fragmentSketch(sk);
                }
                FeatureSketch sketch = new FeatureSketch(ref sk);

                Node[] nodes = new Node[sk.Substrokes.Length];
                for (int i = 0; i < sk.Substrokes.Length; ++i)
                {
                    nodes[i] = new Node(sk.Substrokes[i], lm.translatedClasses.Count, i);
                }

                #region Calculate Features

                double   totalMinDistBetweenFrag     = sketch.TotalMinDistBetweenSubstrokes;
                double   totalAverageDistBetweenFrag = sketch.TotalAvgDistBetweenSubstrokes;
                double   totalMaxDistBetweenFrag     = sketch.TotalMaxDistBetweenSubstrokes;
                double   totalTimeBetweenFrag        = CreateGraph.totTimeBetweenFrag(nodes);
                double   totalArcLength          = sketch.TotalArcLength;
                double   totalLengthOfFrag       = sketch.TotalDistance;
                double   averageSpeedOfFrag      = sketch.AverageAverageSpeed;
                double   totalMinDistBetweenEnds = sketch.TotalMinDistBetweenSubstrokes;
                double[] bbox = sketch.BBox.ToArray();


                SiteFeatures.setStageNumber(1);
                InteractionFeatures.setStageNumber(1);
                SiteFeatures site = new SiteFeatures(totalMinDistBetweenFrag,
                                                     totalAverageDistBetweenFrag,
                                                     totalMaxDistBetweenFrag,
                                                     totalTimeBetweenFrag,
                                                     totalArcLength,
                                                     totalLengthOfFrag,
                                                     averageSpeedOfFrag,
                                                     totalMinDistBetweenEnds,
                                                     bbox, ref sketch);
                InteractionFeatures inter = new InteractionFeatures(totalMinDistBetweenFrag,
                                                                    totalAverageDistBetweenFrag,
                                                                    totalMaxDistBetweenFrag,
                                                                    totalTimeBetweenFrag,
                                                                    totalArcLength,
                                                                    totalLengthOfFrag,
                                                                    averageSpeedOfFrag,
                                                                    totalMinDistBetweenEnds,
                                                                    ref sketch);

                #endregion

                #region Write out

                for (int i = 0; i < nodes.Length; ++i)
                {
                    if (!lm.labelMap.ContainsKey(sk.Substrokes[i].FirstLabel))
                    {
                        Console.WriteLine("Label {0} not found in label map, continuing", sk.Substrokes[i].FirstLabel);
                        continue;
                    }
                    double[] ret    = site.evalSiteFeatures(nodes[i], sk.Substrokes);
                    int      allIdx = addSSStrokeToDTF(ref all, ref ret, ref sk.Substrokes[i], ref lm);
                    ret = aggregateInteractionFeatures(inter, nodes[i], nodes, sk.Substrokes);
                    addMSStrokeToDTF(ref all, ref ret, allIdx);
                }

                #endregion
            }
            Console.Write(Environment.NewLine);
            all.WriteDataFile(outputDirectory + "\\all.data");
            Console.WriteLine("DTF Calculations finished at {0}", DateTime.Now.ToShortTimeString());
        }
Пример #19
0
    protected void Page_Load(object sender, EventArgs e)
    {
        string CompanyName = Session["company"].ToString();

        id_ShoutKeyword.InnerHtml += CompanyName;
        //------------------------------------------------------------------------------------------
        CompanyName = CompanyName.ToLower();
        CompanyName = CompanyName.Replace('ö', 'o');
        CompanyName = CompanyName.Replace('ü', 'u');
        CompanyName = CompanyName.Replace('ğ', 'g');
        CompanyName = CompanyName.Replace('ş', 's');
        CompanyName = CompanyName.Replace('ı', 'i');

        //------------------------------------------------------------------------------------------

        var    GSearch = new GoogleSearch(CompanyName);
        string URL     = null;

        //istenilen şirketin url'sini alma http://companyname.com
        foreach (var item in GSearch.GoogleSearch_().Items)
        {
            URL = Server.HtmlEncode(item.Link); break;
        }

        //Host www.companyname.com
        UriParser up = new UriParser(URL);

        up.UriParse();
        string host = up.host.Remove(0, 4);

        //IP ------------------------------------------------------------------------------------------------
        GetIPAddress ip = new GetIPAddress(host);

        IPAddress[] IP = ip.GetIP();

        // Company Bileşenlerini setleme ------------------------------------------------------------------------------------
        CreateGraph cg = new CreateGraph();

        cg.CreateRootNode();

        Company_Node comp = new Company_Node {
            name = CompanyName, comp_host = host, comp_ip = IP[0].ToString()
        };

        cg.CreateRelationRoot_Company(comp);
        Shodan_Node sh = new Shodan_Node {
            name = "Shodan" + CompanyName.Replace(" ", "")
        };

        cg.CreateRelationCompany_Shodan(sh, comp);

        //ShodanApi----------------------------------------------------------------------------------------------------------------------------
        Dictionary <string, object> ShodanResults = new Dictionary <string, object>();
        SeeResult Shodan = new SeeResult(IP[0]);

        ShodanResults = Shodan.SearchResult();
        Shodan_Node.SmallNodes_Ports port = new Shodan_Node.SmallNodes_Ports();

        foreach (KeyValuePair <string, object> item in ShodanResults)
        {
            if (item.Key == "ports")
            {
                var obj = ((IEnumerable)item.Value).Cast <object>().ToList();
                foreach (var item2 in obj)
                {
                    port.ports = item2.ToString();
                    cg.CreateRelationShodan_Ports(sh, port);
                }
            }
        }



        //string shodanResults = string.Join(Environment.NewLine, ShodanResults.Select(x => x.Key + " = " + x.Value).ToArray());

        Shodan_Node.SmallNodes_ASN         _asn    = new Shodan_Node.SmallNodes_ASN();
        Shodan_Node.SmallNodes_CountryName country = new Shodan_Node.SmallNodes_CountryName();
        Shodan_Node.SmallNodes_IPsTR       ipStr   = new Shodan_Node.SmallNodes_IPsTR();
        Shodan_Node.SmallNodes_Isp         _isp    = new Shodan_Node.SmallNodes_Isp();
        Shodan_Node.SmallNodes_LastUp      lastup  = new Shodan_Node.SmallNodes_LastUp();
        Shodan_Node.SmallNodes_Org         org     = new Shodan_Node.SmallNodes_Org();
        foreach (KeyValuePair <string, object> item in ShodanResults)
        {
            if (item.Key == "org")
            {
                org.org = item.Value.ToString(); cg.CreateRelationShodan_org(sh, org);
            }
            else if (item.Key == "isp")
            {
                _isp.isp = item.Value.ToString(); cg.CreateRelationShodan_Isp(sh, _isp);
            }
            else if (item.Key == "last_update")
            {
                lastup.last_update = item.Value.ToString(); cg.CreateRelationShodan_LastUpdate(sh, lastup);
            }
            else if (item.Key == "country_name")
            {
                country.country_name = item.Value.ToString(); cg.CreateRelationShodan_CountryName(sh, country);
            }
            else if (item.Key == "ip_str")
            {
                ipStr.ip_str = item.Value.ToString(); cg.CreateRelationShodan_IPsTR(sh, ipStr);
            }
            else if (item.Key == "asn")
            {
                _asn.asn = item.Value.ToString(); cg.CreateRelationShodan_ASN(sh, _asn);
            }
        }



        //Whois ------------------------------------------------------------------------------------------------------------------------------------
        var        whois = new WhoisLookup().Lookup(host);
        Whois_Node who   = new Whois_Node();

        who.WhoisText = whois.Text.ToArray(typeof(string)) as string[];
        cg.CreateRelationCompany_Whois(who, comp);

        //Geocoder------------------------------------------------------------------------------------------------------------------------------------
        GeoCoderInformation.GeocoderInfo GeoInfo = new GeoCoderInformation.GeocoderInfo(CompanyName);
        Geocode_Node geoname = new Geocode_Node();
        GeoLatitude  _lat    = new GeoLatitude();
        GeoLongitude _lon    = new GeoLongitude();

        foreach (var item in GeoInfo.GetGeocodeResponse().results)
        {
            foreach (var item2 in item.address_components)
            {
                geoname.name = item2.long_name;
                _lat.Geo_lat = item.geometry.location.lat;
                _lon.Geo_lon = item.geometry.location.lng;
            }
            cg.CreateRelationCompany_Geocode(geoname, comp, _lon, _lat);
        }


        //WikiData---------------------------------------------------------------------------------------------------------------------

        GetWikiData.WikiData wiki = new GetWikiData.WikiData(CompanyName);
        wiki.GetWikiData();
        Wikipedia_Node wikinode = new Wikipedia_Node {
            name = wiki.Title.Replace("'", ""), description = wiki.Description.Replace("'", "")
        };

        cg.CreateRelationCompany_Wikipedia(wikinode, comp);
        //Google Search --------------------------------------------------------------------------------------------------------------

        GoogleSearchEngine.GoogleSearch Gsearch = new GoogleSearchEngine.GoogleSearch(CompanyName);
        Facebook_Node fb = new Facebook_Node();

        foreach (var item in Gsearch.FacebookSearch().Items)
        {
            fb.name   = item.Title.Replace("'", "");
            fb.fb_url = item.Link;
            cg.CreateRelationCompany_Facebook(fb, comp);
        }
        GooglePlus_Node _gp = new GooglePlus_Node();

        foreach (var item in Gsearch.GooglePlusSearch().Items)
        {
            _gp.name   = item.Title.Replace("'", "");
            _gp.gp_url = item.Link;
            cg.CreateRelationCompany_GooglePlus(_gp, comp);
        }
        Linkedin_Node ln = new Linkedin_Node();

        foreach (var item in Gsearch.LinkedinSearch().Items)
        {
            ln.name    = item.Title.Replace("'", "");
            ln.lin_url = item.Link;
            cg.CreateRelationCompany_Linkedin(ln, comp);
        }
        GoogleNews_Node _gn = new GoogleNews_Node();

        foreach (var item in Gsearch.NewsSearch().Items)
        {
            _gn.name   = item.Title.Replace("'", "");
            _gn.gn_url = item.Link;
            cg.CreateRelationCompany_GoogleNews(_gn, comp);
        }
        Reddit_Node red = new Reddit_Node();

        foreach (var item in GSearch.RedditSearch().Items)
        {
            red.name    = item.Title.Replace("'", "");
            red.red_url = item.Link;
            cg.CreateRelationCompany_Reddit(red, comp);
        }
        Twitter_Node tw = new Twitter_Node();

        foreach (var item in Gsearch.TwitterSearch().Items)
        {
            tw.name   = item.Title.Replace("'", "");
            tw.tw_url = item.Link;
            cg.CreateRelationCompany_Twitter(tw, comp);
        }



        //-------------------GET NEO4J COMPANY DATA-----------------------------------



        var graphClient = new GraphClient(new Uri(uri), Db_id, DB_pass);

        graphClient.Connect();


        var FacebookQuery = graphClient.Cypher
                            .Match("p=(c { name: '" + CompanyName + "' })-[:Facebook]->(f)")
                            .Return(f => f.As <GetData._Facebook_Node>())
                            .Results;

        foreach (var item in FacebookQuery)
        {
            facebookContent.InnerHtml += "<a href='" + item.fb_url + "' target='_blank'>" + item.fb_url + "</a><br>";
        }

        var TwitterQuery = graphClient.Cypher
                           .Match("p=(c{name:'" + CompanyName + "'}) -[:Twitter]->(t)")
                           .Return(t => t.As <GetData._Twitter_Node>())
                           .Results;

        foreach (var item in TwitterQuery)
        {
            twitterContent.InnerHtml += "<a href='" + item.tw_url + "' target='_blank'>" + item.tw_url + "</a><br>";
        }

        var RedditQuery = graphClient.Cypher
                          .Match("p=(c{name:'" + CompanyName + "'}) -[:Reddit]->(r)")
                          .Return(r => r.As <GetData._Reddit_Node>())
                          .Results;

        foreach (var item in RedditQuery)
        {
            redditContent.InnerHtml += "<a href='" + item.red_url + "' target='_blank'>" + item.red_url + "</a><br>";
        }

        var LinkedinQuery = graphClient.Cypher
                            .Match("p=(c{name:'" + CompanyName + "'})-[:Linkedin]->(l)")
                            .Return(l => l.As <GetData._Linkedin_Node>())
                            .Results;

        foreach (var item in LinkedinQuery)
        {
            linkedinContent.InnerHtml += "<a href='" + item.lin_url + "' target='_blank'>" + item.lin_url + "</a><br>";
        }

        var GoogleNewsQuery = graphClient.Cypher
                              .Match("p=(c{name:'" + CompanyName + "'})-[:GoogleNews]->(gn)")
                              .Return(gn => gn.As <GetData._GoogleNews_Node>())
                              .Results;

        foreach (var item in GoogleNewsQuery)
        {
            googlenewsContent.InnerHtml += "<a href='" + item.gn_url + "' target='_blank'>" + item.gn_url + "</a><br>";
        }

        var GooglePlusQuery = graphClient.Cypher
                              .Match("p=(c{name:'" + CompanyName + "'})-[:GooglePlus]->(gp)")
                              .Return(gp => gp.As <GetData._GooglePlus_Node>())
                              .Results;

        foreach (var item in GooglePlusQuery)
        {
            googleplusContent.InnerHtml += "<a href='" + item.gp_url + "' target='_blank'>" + item.gp_url + "</a><br>";
        }

        var WhoisQuery = graphClient.Cypher
                         .Match("p=(c{name:'" + CompanyName + "'})-[:Whois]->(wh)")
                         .Return(wh => wh.As <GetData._Whois_Node>())
                         .Results;

        foreach (var item in WhoisQuery)
        {
            for (int i = 0; i < item.WhoisText.Length; i++)
            {
                whoisContent.InnerHtml += item.WhoisText[i] + "<br>";
            }
        }


        var WikipediaQuery = graphClient.Cypher
                             .Match("p=(c{name:'" + CompanyName + "'})-[:Wikipedia]->(w)")
                             .Return(w => w.As <GetData._Wikipedia_Node>())
                             .Results;

        foreach (var item in WikipediaQuery)
        {
            if (item.description == "" || item.description == null)
            {
                wikipediaContent.InnerHtml += "No Records Found";
            }
            else
            {
                wikipediaContent.InnerHtml += item.description;
            }
        }

        var ShodanORGQuery = graphClient.Cypher
                             .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:ORG]->(Org)")
                             .Return(Org => Org.As <GetData._Shodan_Node._SmallNodes_Org>())
                             .Results;

        foreach (var item in ShodanORGQuery)
        {
            if (ShodanORGQuery.Count() == 0)
            {
                orgContent.InnerHtml += "No Record Found!";
            }
            else
            {
                orgContent.InnerHtml += item.org + "<br>";
            }
        }

        var ShodanISPQuery = graphClient.Cypher
                             .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:ISP]->(isp)")
                             .Return(isp => isp.As <GetData._Shodan_Node._SmallNodes_Isp>())
                             .Results;

        foreach (var item in ShodanISPQuery)
        {
            if (ShodanISPQuery.Count() == 0)
            {
                ispContent.InnerHtml += "No Record Found!";
            }
            else
            {
                ispContent.InnerHtml += item.isp + "<br>";
            }
        }

        var ShodanLASTUPQuery = graphClient.Cypher
                                .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:LastUpdate]->(LastUp)")
                                .Return(LastUp => LastUp.As <GetData._Shodan_Node._SmallNodes_LastUp>())
                                .Results;

        foreach (var item in ShodanLASTUPQuery)
        {
            if (ShodanLASTUPQuery.Count() == 0)
            {
                lastupContent.InnerHtml += "No Record Found!";
            }
            else
            {
                lastupContent.InnerHtml += item.last_update + "<br>";
            }
        }

        var ShodanCOUNTRYQuery = graphClient.Cypher
                                 .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:COUNTRY]->(CountryName)")
                                 .Return(CountryName => CountryName.As <GetData._Shodan_Node._SmallNodes_CountryName>())
                                 .Results;

        foreach (var item in ShodanCOUNTRYQuery)
        {
            if (ShodanCOUNTRYQuery.Count() == 0)
            {
                countryContent.InnerHtml += "No Record Found!";
            }
            else
            {
                countryContent.InnerHtml += item.country_name + "<br>";
            }
        }

        var ShodanIPSTRQuery = graphClient.Cypher
                               .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:IPSTR]->(ip_str)")
                               .Return(ip_str => ip_str.As <GetData._Shodan_Node._SmallNodes_IPsTR>())
                               .Results;

        foreach (var item in ShodanIPSTRQuery)
        {
            if (ShodanIPSTRQuery.Count() == 0)
            {
                ipstrContent.InnerHtml += "No Record Found!";
            }
            else
            {
                ipstrContent.InnerHtml += item.ip_str + "<br>";
            }
        }

        var ShodanASNQuery = graphClient.Cypher
                             .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:ASN]->(asn)")
                             .Return(asn => asn.As <GetData._Shodan_Node._SmallNodes_ASN>())
                             .Results;

        foreach (var item in ShodanASNQuery)
        {
            if (ShodanASNQuery.Count() == 0)
            {
                asnContent.InnerHtml += "No Record Found!";
            }
            else
            {
                asnContent.InnerHtml += item.asn + "<br>";
            }
        }

        var ShodanPORTQuery = graphClient.Cypher
                              .Match("p=(sh {name:'Shodan" + CompanyName + "'})-[:OPEN_PORT]->(ports)")
                              .Return(ports => ports.As <GetData._Shodan_Node._SmallNodes_Ports>())
                              .Results;

        foreach (var item in ShodanPORTQuery)
        {
            if (ShodanPORTQuery.Count() == 0)
            {
                portContent.InnerHtml += "No Record Found!";
            }
            else
            {
                portContent.InnerHtml += item.ports + "<br>";
            }
        }

        var GeocodeQuery = graphClient.Cypher
                           .Match("p=(c{name:'" + CompanyName + "'})-[:Geocode]->(geo)")
                           .Return(geo => geo.As <GetData._Geocode_Node>()).Results;

        foreach (var item in GeocodeQuery)
        {
            GeocodeContent.InnerHtml += "<h3>" + item.name + "</h3><br>";
            var GeoLonQuery = graphClient.Cypher.Match("(geo{name:'" + item.name + "'})-[:longitude]->(lon)").Return(lon => lon.As <GetData._GeoLongitude>()).Results;
            foreach (var itemLon in GeoLonQuery)
            {
                GeocodeContent.InnerHtml += "<b>Longitude</b>" + itemLon.Geo_lon + "&nbsp&nbsp&nbsp&nbsp";
            }
            var GeoLatQuery = graphClient.Cypher.Match("(geo{name:'" + item.name + "'})-[:latitude]->(lat)").Return(lat => lat.As <GetData._GeoLatitude>()).Results;
            foreach (var itemLat in GeoLatQuery)
            {
                GeocodeContent.InnerHtml += "<b>Latitude</b>" + itemLat.Geo_lat;
            }
        }
    }
Пример #20
0
    /* #endregion */

    /* #region ---- Set pathfinding ----------------------------------------------------------- */
    void createPathFinding()
    {
        CreateGraph = new CreateGraph(MatchManager);
        PathFinding = new PathFinding();
        CreateGraph.AddNeighbourTiles();
    }
Пример #21
0
 public void Awake()
 {
     graph = CreateGraph.GenerateGraph(firstNode, numberOfPoints);
 }