All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jbpt.petri.unfolding.OccurrenceNet Maven / Gradle / Ivy

Go to download

The jBPT code library is a compendium of technologies that support research on design, execution, and evaluation of business processes.

The newest version!
package org.jbpt.petri.unfolding;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;

import org.jbpt.petri.Flow;
import org.jbpt.petri.Marking;
import org.jbpt.petri.Node;
import org.jbpt.petri.PetriNet;
import org.jbpt.petri.Place;
import org.jbpt.petri.Transition;

public class OccurrenceNet extends
		AbstractOccurrenceNet {

	protected OccurrenceNet() {
		super();
	}

	protected OccurrenceNet(ICompletePrefixUnfolding unf) {
		super(unf);
	}

	@Override
	public Flow addFlow(Node from, Node to) {
		if (from == null || to == null) return null;
		
		if ((from instanceof Place && to instanceof Transition) ||
				from instanceof Transition && to instanceof Place) {
			
			Collection ss = new ArrayList(); ss.add(from);
			Collection ts = new ArrayList(); ts.add(to);
			
			if (!this.checkEdge(ss,ts)) return null;
			
			return new Flow(this, from, to);
		}
		
		return null;
	}

	@Override
	public Set getSourceNodes() {
		return PetriNet.DIRECTED_GRAPH_ALGORITHMS.getSources(this);
	}
	
	@Override
	public Set getSinkNodes() {
		return PetriNet.DIRECTED_GRAPH_ALGORITHMS.getSinks(this);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy