Class EgonetGraphGenerator<V,E>

java.lang.Object
org.jgrapht.generate.EgonetGraphGenerator<V,E>
Type Parameters:
V - the graph vertex type
E - the graph edge type
All Implemented Interfaces:
GraphGenerator<V,E,V>

public class EgonetGraphGenerator<V,E> extends Object implements GraphGenerator<V,E,V>
Generator that produces the egonet of a given vertex in a graph.

The general egonet description that led to this implementation is described in the paper: Linton C. Freeman (1981), Centered Graphs and The Structure of Ego Networks.

The generator searches for paths from the given ego vertex to all vertices within the specified radius and generates a new graph containing the vertices found, along with the edges connecting them.

The distance of the vertices included on the resulting graph can be configured by using a custom radius, along with whether the new graph should include the original ego vertex and whether new edge objects should be used.

Note that this implementation works with undirected graphs by using the Breadth-First Shortest Path algorithm, and with directed graphs by using Dijkstra's Shortest Path algorithm.

Author:
Fotis Karagiannis
  • Field Details

    • DEFAULT_RADIUS

      public static final int DEFAULT_RADIUS
      Default constructor radius
      See Also:
    • DEFAULT_INCLUDE_EGO

      public static final boolean DEFAULT_INCLUDE_EGO
      Default constructor ego inclusion
      See Also:
    • DEFAULT_USE_NEW_EDGES

      public static final boolean DEFAULT_USE_NEW_EDGES
      Default constructor new edge usage
      See Also:
  • Constructor Details

    • EgonetGraphGenerator

      public EgonetGraphGenerator(Graph<V,E> graph, V ego, int radius, boolean includeEgo, boolean newEdges)
      Constructor
      Parameters:
      graph - the given graph
      ego - the ego vertex (must belong to the graph)
      radius - the limit on path length
      includeEgo - include ego on the generated graph option
      newEdges - use new edge objects option
    • EgonetGraphGenerator

      public EgonetGraphGenerator(Graph<V,E> graph, V ego, int radius, boolean includeEgo)
    • EgonetGraphGenerator

      public EgonetGraphGenerator(Graph<V,E> graph, V ego, int radius)
    • EgonetGraphGenerator

      public EgonetGraphGenerator(Graph<V,E> graph, V ego, boolean includeEgo)
    • EgonetGraphGenerator

      public EgonetGraphGenerator(Graph<V,E> graph, V ego)
  • Method Details

    • generateGraph

      public void generateGraph(Graph<V,E> target, Map<String,V> resultMap)
      Description copied from interface: GraphGenerator
      Generate a graph structure. The topology of the generated graph is dependent on the implementation. For graphs in which not all vertices share the same automorphism equivalence class, the generator may produce a labeling indicating the roles played by generated elements. This is the purpose of the resultMap parameter. For example, a generator for a wheel graph would designate a hub vertex. Role names used as keys in resultMap should be declared as public static final Strings by implementation classes.
      Specified by:
      generateGraph in interface GraphGenerator<V,E,V>
      Parameters:
      target - receives the generated edges and vertices; if this is non-empty on entry, the result will be a disconnected graph since generated elements will not be connected to existing elements
      resultMap - if non-null, receives implementation-specific mappings from String roles to graph elements (or collections of graph elements)