java.lang.Object
org.unifi.mecvirtualresourceallocation.graph.HyperGraph

public final class HyperGraph extends Object
This class represents a hypergraph, which consists of a set of hyperedges and vertices. In the context of Mobile Edge Computing (MEC), a hypergraph is used to model the complex relationships between virtual machine (VM) instances and physical machines (PMs). Each hyperedge connects multiple vertices (VMs).
  • Constructor Details

    • HyperGraph

      public HyperGraph(Set<Vertex> vertices, Set<HyperEdge> hyperEdges)
      Constructs a hypergraph with the specified vertices and hyperedges.
      Parameters:
      vertices - the vertices of the hypergraph
      hyperEdges - the hyperedges of the hypergraph
    • HyperGraph

      public HyperGraph(int[][] placementMatrix, double[] weights)
      Constructs a hypergraph from a placement matrix and vertex weights. The order of vertices is determined by their corresponding weights in the weights array, which must match the order of rows in the placement matrix.
      Parameters:
      placementMatrix - the placement matrix where rows represent vertices and columns represent hyperedges. Each element should be 1 if the corresponding vertex is part of the hyperedge, otherwise 0
      weights - the array of weights for the vertices. The order of weights must match the order of rows in the placement matrix
      Throws:
      IllegalArgumentException - if the number of weights does not match the number of rows in the placement matrix
  • Method Details

    • getVertices

      public Set<Vertex> getVertices()
      Gets the vertices of the hypergraph.
      Returns:
      the vertices
    • getHyperEdges

      public Set<HyperEdge> getHyperEdges()
      Gets the hyperedges of the hypergraph.
      Returns:
      the hyperedges
    • addHyperEdge

      public void addHyperEdge(HyperEdge hyperEdge)
      Adds a hyperedge to the hypergraph, ensuring no duplicate hyperedge IDs exist. The vertices of the hyperedge are also added to the hypergraph if not already present.
      Parameters:
      hyperEdge - the hyperedge to be added
      Throws:
      IllegalArgumentException - if the hyperedge has no vertices or if there are duplicate IDs
    • getConflictGraph

      public ConflictGraph getConflictGraph()
      Generates a conflict graph based on the hypergraph. The conflict graph represents conflicts between hyperedges where conflicts are defined by the presence of common vertices.
      Returns:
      the generated conflict graph
    • printPlacementMatrix

      public void printPlacementMatrix()
      Prints the placement matrix to the console.
    • getPlacementMatrix

      public int[][] getPlacementMatrix()
      Generates and returns a placement matrix based on the current hypergraph.
      Returns:
      the placement matrix where rows represent vertices and columns represent hyperedges Each element is 1 if the corresponding vertex is part of the hyperedge, otherwise 0
    • toString

      public String toString()
      Returns a string representation of the hypergraph, including its vertices and hyperedges.
      Overrides:
      toString in class Object
      Returns:
      a string representation of the hypergraph
    • showGraph

      public void showGraph()
      Displays the hypergraph using a graphical user interface.
    • saveToSvg

      public void saveToSvg(String filePath)
      Saves the current hypergraph visualization as an SVG file. The file is saved as "hypergraph.svg" in the current directory.
      Parameters:
      filePath - The file path where the SVG file will be saved