public DependencyGraph(IState persistentState) { var state = persistentState as DependencyGraphState; if (state == null) { throw new WorkflowEngineException( "DependencyGraph must be loaded with an object of type DependencyGraphState"); } _executedPlugins = state.ExecutedPlugins; _consumes = state.Consumes.ToDictionary(kv => new PluginId(kv.Key), kv => kv.Value); _createdBy = state.CreatedBy.ToDictionary(kv => new PluginDataId(kv.Key), kv => kv.Value); _graph = new BidirectionalGraph <PluginId, SEdge <PluginId> >(); using (var stream = new MemoryStream()) { using (var streamWriter = new StreamWriter(stream)) { streamWriter.Write(state.Graph); streamWriter.Flush(); stream.Position = 0; using (var xmlReader = XmlReader.Create(stream)) { var vertexFactory = new IdentifiableVertexFactory <PluginId>(pluginId => new PluginId(pluginId)); var edgeFactory = new IdentifiableEdgeFactory <PluginId, SEdge <PluginId> >((source, target, id) => new SEdge <PluginId>(source, target)); _graph.DeserializeFromGraphML(xmlReader, vertexFactory, edgeFactory); } } } }
public static BidirectionalGraph <string, Edge <string> > LoadBidirectionalGraph([NotNull] string graphMLFilePath) { var graph = new BidirectionalGraph <string, Edge <string> >(); using (var reader = new StreamReader(graphMLFilePath)) { graph.DeserializeFromGraphML( reader, id => id, (source, target, _) => new Edge <string>(source, target)); } return(graph); }
public static BidirectionalGraph<string, Edge<string>> LoadBidirectionalGraph(string graphmlFile) { TestConsole.WriteLine(graphmlFile); var g = new BidirectionalGraph<string, Edge<string>>(); using (var reader = new StreamReader(graphmlFile)) { g.DeserializeFromGraphML( reader, id => id, (source, target, id) => new Edge<string>(source, target) ); } return g; }
public static BidirectionalGraph <string, Edge <string> > LoadBidirectionalGraph(string graphmlFile) { TestConsole.WriteLine(graphmlFile); var g = new BidirectionalGraph <string, Edge <string> >(); using (var reader = new StreamReader(graphmlFile)) { g.DeserializeFromGraphML( reader, id => id, (source, target, id) => new Edge <string>(source, target) ); } return(g); }