Class BigraphUtil

java.lang.Object
org.bigraphs.framework.core.utils.BigraphUtil

public class BigraphUtil extends Object
A collection of useful bigraph-related operations and queries.
Author:
Dominik Grzelak
  • Constructor Details

    • BigraphUtil

      public BigraphUtil()
  • Method Details

    • copyIfSame

      public static <S extends AbstractEcoreSignature<? extends Control<?, ?>>> Bigraph<S> copyIfSame(Bigraph<S> g, Bigraph<S> f)
    • copy

      public static <S extends AbstractEcoreSignature<? extends Control<?, ?>>> Bigraph<S> copy(Bigraph<S> f)
    • copy

      public static EcoreBigraph copy(EcoreBigraph bigraph) throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • toBigraph

    • toBigraph

      public static PureBigraph toBigraph(org.eclipse.emf.ecore.EPackage metaModel, org.eclipse.emf.ecore.EObject instanceModel, DefaultDynamicSignature signature)
    • setParentOfNode

      public static void setParentOfNode(BigraphEntity<?> node, BigraphEntity<?> parent)
    • setParentOfNode

      public static void setParentOfNode(org.eclipse.emf.ecore.EObject node, org.eclipse.emf.ecore.EObject parent)
    • isSomeParentOfNode

      public static boolean isSomeParentOfNode(BigraphEntity<?> node, BigraphEntity<?> possibleParent, Bigraph<?> bigraph)
    • getUniqueLabelOfBigraphEntity

      public static String getUniqueLabelOfBigraphEntity(BigraphEntity x)
      Returns the common label of an bigraph entity (a node, root, outer name, ...). Interface elements are prefixed such as "s" for sites, and "r" for roots.

      Similar to getUniqueIdOfBigraphEntity(BigraphEntity) but here for a node the control label is used instead of its name id.

      Parameters:
      x -
      Returns:
    • getUniqueIdOfBigraphEntity

      public static String getUniqueIdOfBigraphEntity(BigraphEntity x)
      Returns the unique id of an bigraph entity (a node, root, outer name, ...). Interface elements are prefixed such as "s" for sites, and "r" for roots.

      Similar to getUniqueLabelOfBigraphEntity(BigraphEntity) but here for node the name id is used instead of the control label.

      Parameters:
      x -
      Returns:
    • reorderBigraphs

      public static Bigraph reorderBigraphs(List<Bigraph> discreteBigraphs, InstantiationMap instantiationMap) throws IncompatibleSignatureException, IncompatibleInterfaceException
      Each bigraph represents a "parameter" in a list. The result of this method is the product of all parameters discreteBigraphs but each parameter is getting a new root index due to the instantiation map. The instantiation map maps the position of the initial bigraphs to a new one in the list. The resulting bigraph has as many roots as parameters in the list.
      Parameters:
      discreteBigraphs - list of bigraphs (parameters)
      instantiationMap - an instantiation map
      Returns:
      a bigraph containing all "parameters" in a new order. It has as many roots as the list size of discreteBigraphs.
      Throws:
      IncompatibleSignatureException
      IncompatibleInterfaceException
    • mergeSignatures

      public static DefaultDynamicSignature mergeSignatures(DefaultDynamicSignature left, DefaultDynamicSignature right)
      This method merges the two given signatures left and right. A completely new instance will be created with a new underlying Ecore signature metamodel.

      If either one of the given signatures is null, the other one is simply returned.

      Merging signatures does not require the two signatures to be consistent. If both do not contain the same control labels, then merge is just like composition.

      For same control labels, the left signature overrides the right one.

      Parameters:
      left - a signature
      right - another signature to merge with left
      Returns:
      a merged signature, or just left or right, if the other one is null
      Throws:
      RuntimeException - if the underlying metamodel is invalid, that is created in the merging process.
    • mergeSignatures

      public static DefaultDynamicSignature mergeSignatures(DefaultDynamicSignature left, DefaultDynamicSignature right, int leftOrRight)
      This method merges the two given signatures left and right. A completely new instance will be created with a new underlying Ecore signature metamodel.

      If either one of the given signatures is null, the other one is simply returned.

      Merging signatures does not require the two signatures to be consistent. If both do not contain the same control labels, then merge is just like composition.

      For same control labels, the argument leftOrRight specifies whether the left signature overrides the right one: 0 means the left signature has precedence, and 1 means the right signature has precedence.

      Parameters:
      left - the first signature
      right - the second signature to merge with the first one
      leftOrRight - whether to use the left or right signature if same controls found in both
      Returns:
      the new merge signature
    • composeSignatures

      public static DefaultDynamicSignature composeSignatures(DefaultDynamicSignature left, DefaultDynamicSignature right)
      This method composes the two given signatures left and right. A completely new instance will be created with a new underlying Ecore signature metamodel.

      If either one of the given signatures is null, the other one is simply returned.

      Signatures are required to be consistent, i.e., both signatures have either different control labels, or if they contain the same label, they must agree on the arity and status.

      Parameters:
      left - a signature
      right - another signature to compose with left
      Returns:
      a composed signature, or just left or right, if the other one is null
      Throws:
      RuntimeException - if the signatures are not consistent
    • composeSignatures

      public static Optional<DefaultDynamicSignature> composeSignatures(List<DefaultDynamicSignature> signatures)
    • leftMergeSignatures

      public static Optional<DefaultDynamicSignature> leftMergeSignatures(List<DefaultDynamicSignature> signatures)
    • zip

      public static <T, U> Stream<Map.Entry<T,U>> zip(Stream<T> stream1, Stream<U> stream2)
    • isElementaryBigraph

      public static boolean isElementaryBigraph(Bigraph<?> bigraph)
      Basic checking method for simple elementary bigraphs such as a merge or closure. This doesn't work for a Discrete Ion or a molecule, for instance.
      Parameters:
      bigraph - the bigraph to check
      Returns:
      true, if bigraph is a simple elementary one (except for a discrete ion, for example).
    • isBigraphElementaryLinking

      public static boolean isBigraphElementaryLinking(Bigraph<?> bigraph)
    • isBigraphElementaryPlacing

      public static boolean isBigraphElementaryPlacing(Bigraph<?> bigraph)