/// <summary> /// Build a List of Columns from a PetriNet /// </summary> /// <param name="petriNet"></param> /// <returns></returns> /// <author>Jannik Arndt</author> public static List<Column> Build(PetriNet petriNet) { // Initialize GlobalColumnList.Clear(); Column firstColumn = new Column(0); Place startPlace = (Place) petriNet.GetSources()[0]; firstColumn.HashSetOfNodes.Add(startPlace); GlobalColumnList.Add(firstColumn); // Recursively add all columns AddPlace(startPlace, 1); // Correct the end-place Place endPlace = (Place) petriNet.GetSinks()[0]; Column temp = FindNode(endPlace); if (temp != null && temp.ColumnNumber < GlobalColumnList.Count) { temp.HashSetOfNodes.Remove(endPlace); TrimGlobalColumnList(); GetOrCreateColumn(GlobalColumnList.Count).HashSetOfNodes.Add(endPlace); } return GlobalColumnList; }
/// <summary> /// Adds another PetriNet to this at the given Transition (since the other PetriNet should start with a place). /// Keep in mind to close all open sinks afterwards! /// </summary> /// <param name="petriNet">The other PetriNet</param> /// <param name="atTransition">A transition in THIS PetriNet, where the added net will be connected</param> /// <author>Jannik Arndt</author> public void MergeWithPetriNet(PetriNet petriNet, Transition atTransition) { List <Node> sources = petriNet.GetSources(); if (sources.Count > 0) { atTransition.OutgoingPlaces.Add((sources[0] as Place)); atTransition.OutgoingPlaces[0].AppendIncomingTransition(atTransition); Transitions.AddRange(petriNet.Transitions); Places.AddRange(petriNet.Places); } }
/// <summary> /// Adds another PetriNet to this at the given Transition (since the other PetriNet should start with a place). /// Keep in mind to close all open sinks afterwards! /// </summary> /// <param name="petriNet">The other PetriNet</param> /// <param name="atTransition">A transition in THIS PetriNet, where the added net will be connected</param> /// <author>Jannik Arndt</author> public void MergeWithPetriNet(PetriNet petriNet, Transition atTransition) { List<Node> sources = petriNet.GetSources(); if (sources.Count > 0) { atTransition.OutgoingPlaces.Add((sources[0] as Place)); atTransition.OutgoingPlaces[0].AppendIncomingTransition(atTransition); Transitions.AddRange(petriNet.Transitions); Places.AddRange(petriNet.Places); } }