/// <summary> /// Creates a node and any other connected nodes from a serialised execution graph /// </summary> /// <param name="factory"></param> /// <param name="graph">Serialised graph</param> public static INode CreateFrom(this GraphFactory factory, Models.ExecutionGraph graph) { // create the input node var nodeTable = new Dictionary <string, INode>(); var ret = factory.Create(graph.InputNode); nodeTable.Add(ret.Id, ret); // create the other nodes foreach (var node in graph.OtherNodes) { var n = factory.Create(node); if (!nodeTable.ContainsKey(n.Id)) { nodeTable.Add(n.Id, n); } } // let each node know it has been deserialised and access to the entire graph foreach (var item in nodeTable) { item.Value.OnDeserialise(nodeTable); } // create the wires between nodes foreach (var wire in graph.Wires) { var from = nodeTable[wire.FromId]; var to = nodeTable[wire.ToId]; from.Output.Add(new WireToNode(to, wire.InputChannel)); } return(ret); }
/// <summary> /// Reads serialisation information and creates a node /// </summary> /// <param name="factory"></param> /// <param name="reader"></param> /// <returns></returns> protected static INode _Hydrate(GraphFactory factory, BinaryReader reader) { var bufferSize = reader.ReadInt32(); Models.ExecutionGraph.Node model; using (var buffer = new MemoryStream(reader.ReadBytes(bufferSize))) model = Serializer.Deserialize <Models.ExecutionGraph.Node>(buffer); return(factory?.Create(model)); }
private void CreateNewGraph(int verticesCount, bool oriented) { if (!CheckChangesSaved()) { return; } Graph = GraphFactory.Create(verticesCount, oriented); FileName = ""; InitGraph(); ChangesSaved = false; }
static void Main(string[] args) { var factory = new GraphFactory(); var inputGraph = factory.Create(); Console.WriteLine("Please enter how many people you have or 0 if do not konw"); var avaliableResource = int.Parse(Console.ReadLine()); Console.WriteLine("Scheudling with " + avaliableResource + " resources"); var feedDataFactory = new ScheduleDataFactory(); var feedData = feedDataFactory.Create(inputGraph, avaliableResource); var scheduler = new Scheduler(); var scheduledList = scheduler.Schedule(feedData); var attendenceChart = scheduler.AttendenceChart; printSchedule(scheduledList); Console.WriteLine(); printAttendence(attendenceChart); var utilityFactory = new UtilityDataFactory(); var utilityDataList = utilityFactory.Create(scheduledList); }
protected GraphReader(string graphName, Directionality directionality) { this.Graph = GraphFactory.Create(graphName, directionality); }