/// <summary> /// Connects all open endings to one end-place. This is useful for multiple processmodels in one net or for loops at the end of the net. /// </summary> /// <param name="petriNet">A petrinet with possible open endings</param> /// <returns>The given PetriNet with a fixed ending</returns> /// <author>Jannik Arndt</author> public PetriNet FixEnding(PetriNet petriNet) { if (petriNet.GetTransitionsWithoutFollowersIgnoreLoops().Count > 0) { var endingPlace = petriNet.AddPlace("End"); foreach (var transition in petriNet.GetTransitionsWithoutFollowersIgnoreLoops()) { if (transition.OutgoingPlaces.Count > 0) { var temporaryTransition = petriNet.AddTransition(); transition.OutgoingPlaces[0].AppendOutgoingTransition(temporaryTransition); temporaryTransition.AddIncomingPlace(transition.OutgoingPlaces[0]); temporaryTransition.AddOutgoingPlace(endingPlace); } else { transition.AddOutgoingPlace(endingPlace); } } } return(petriNet); }