private void loadGraphMLToolStripMenuItem_Click(object sender, EventArgs e) { //GraphMLGraphAdapter test, load DialogResult d = cdbOpenGraphML.ShowDialog(); if (d != DialogResult.Cancel) { this.Cursor = Cursors.WaitCursor; Application.DoEvents(); try { System.IO.StreamReader file = new System.IO.StreamReader(cdbOpenGraphML.FileName); string line = file.ReadToEnd(); oGraphMLGraphAdapter = new GraphMLGraphAdapter(); layoutControl1.Graph = oGraphMLGraphAdapter.LoadGraphFromString(line); } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.Cursor = Cursors.Default; //Application.DoEvents(); } }
public void saveGraph(IGraph graph) { GraphMLGraphAdapter graphMlAdapter = new Smrf.NodeXL.Adapters.GraphMLGraphAdapter(); FileStream fs = File.Create("graph.graphml"); graphMlAdapter.SaveGraph(graph, fs); }
public IGraph Generator() { writeFile(); GraphMLGraphAdapter graphMlAdapter = new Smrf.NodeXL.Adapters.GraphMLGraphAdapter(); IGraph graph = graphMlAdapter.LoadGraphFromFile("GraphAsGraphML.txt"); return(graph); }
public IGraph Generator(bool facebook) { GraphMLGraphAdapter graphMlAdapter = new Smrf.NodeXL.Adapters.GraphMLGraphAdapter(); IGraph graph; if (facebook) { graph = graphMlAdapter.LoadGraphFromFile("facebookgraph.graphml"); } else { graph = graphMlAdapter.LoadGraphFromFile("sndata.graphml"); } return(graph); }
TryGetGraphFromGraphDataProvider ( Object graphDataProvider, out IGraph graph ) { Debug.Assert(graphDataProvider != null); Debug.Assert(graphDataProvider is IGraphDataProvider2 || graphDataProvider is IGraphDataProvider); graph = null; GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter(); if (graphDataProvider is IGraphDataProvider2) { String sPathToTemporaryFile = null; if ( !( (IGraphDataProvider2)graphDataProvider ) .TryGetGraphDataAsTemporaryFile(out sPathToTemporaryFile) ) { return (false); } try { graph = oGraphMLGraphAdapter.LoadGraphFromFile( sPathToTemporaryFile); } finally { File.Delete(sPathToTemporaryFile); } } else { String sGraphDataAsGraphML; if ( !( (IGraphDataProvider)graphDataProvider ).TryGetGraphData( out sGraphDataAsGraphML) ) { return (false); } graph = oGraphMLGraphAdapter.LoadGraphFromString( sGraphDataAsGraphML); } return (true); }
private void youTuBeVideoCrawlerToolStripMenuItem_Click(object sender, EventArgs e) { File.Delete(TempXmlFileName); GetGraphData(new YouTubeVideoNetworkGraphDataProvider()); if (File.Exists(TempXmlFileName)) { System.IO.StreamReader file = new System.IO.StreamReader(TempXmlFileName); string line = file.ReadToEnd(); file.Close(); GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter(); layoutControl1.SetAndShowGraph(oGraphMLGraphAdapter.LoadGraphFromString(line)); } else { MessageBox.Show("Error: 請重新選取youTuBe Video!" , "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); m_oGraph = new Graph(); layoutControl1.SetAndShowGraph(m_oGraph); } }
SetUp() { m_oGraphAdapter = new GraphMLGraphAdapter(); m_sTempFileName = Path.GetTempFileName(); }
private void youtubeCrawlerToolStripMenuItem_Click(object sender, EventArgs e) { GetGraphData(new YouTubeUserNetworkGraphDataProvider()); System.IO.StreamReader file = new System.IO.StreamReader(TempXmlFileName); string line = file.ReadToEnd(); GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter(); layoutControl1.Graph = oGraphMLGraphAdapter.LoadGraphFromString(line); }
OpenObject ( String sFileName, out Object oObject ) { Debug.Assert( !String.IsNullOrEmpty(sFileName) ); Debug.Assert( File.Exists(sFileName) ); AssertValid(); oObject = null; // Use a graph adapter to create a graph from the file. IGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter(); oObject = oGraphMLGraphAdapter.LoadGraphFromFile(sFileName); }
GetGraphML ( Microsoft.Office.Interop.Excel.Workbook oWorkbook ) { Debug.Assert(oWorkbook != null); String sGraphML = null; // The graph owned by the NodeXLControl can't be used, because it // doesn't include all the edge and vertex column data needed for // GraphML. Instead, read the graph from the workbook and include all // the necessary data. ReadWorkbookContext oReadWorkbookContext = new ReadWorkbookContext(); oReadWorkbookContext.ReadAllEdgeAndVertexColumns = true; WorkbookReader oWorkbookReader = new WorkbookReader(); IGraph oGraphForGraphML = oWorkbookReader.ReadWorkbook( oWorkbook, oReadWorkbookContext); GraphMLGraphAdapter oGraphMLGraphAdapter = new GraphMLGraphAdapter(); using ( MemoryStream oMemoryStream = new MemoryStream() ) { oGraphMLGraphAdapter.SaveGraph(oGraphForGraphML, oMemoryStream); oMemoryStream.Position = 0; using ( StreamReader oStreamReader = new StreamReader(oMemoryStream) ) { sGraphML = oStreamReader.ReadToEnd(); } } return (sGraphML); }