• Groups edge entries of a graph based on a specified grouping function. This function allows for the aggregation of edges, optionally considering the directionality or bidirectionality of the edges, as well as applying a custom reduction strategy for edge processing.

    Type Parameters

    • TGraph extends default<Attributes, Attributes, Attributes>

      A type extending from the Graph class of 'graphology'.

    Parameters

    • params: {
          edgeReduceStrategy?: "reduceEdges" | "reduceUndirectedEdges" | "reduceDirectedEdges" | "reduceInEdges" | "reduceOutEdges" | "reduceInboundEdges" | "reduceOutboundEdges";
          fn: ((edge) => string);
          graph: TGraph;
          ignoreParallelEdges?: boolean | "bidirectional";
          node?: string | [string, string];
      }

      The parameters for the edge grouping function.

      • Optional edgeReduceStrategy?: "reduceEdges" | "reduceUndirectedEdges" | "reduceDirectedEdges" | "reduceInEdges" | "reduceOutEdges" | "reduceInboundEdges" | "reduceOutboundEdges"

        The edge reduction strategy to use. It's a method name pattern from the Graph class, such as reduceEdges, reduceOutEdges, etc., defining how edges are traversed and reduced.

      • fn: ((edge) => string)
          • (edge): string
          • A function that determines the grouping key for an edge. This function should return a string that represents the key for grouping.

            Parameters

            Returns string

      • graph: TGraph

        The graph instance from 'graphology' to process.

      • Optional ignoreParallelEdges?: boolean | "bidirectional"

        Controls how parallel edges are handled. If set to true, any additional edges of the same direction with matching keys from the key generating function will be ignored. Setting this to "bidirectional" will perform a similar operation, but ignores directionality.

      • Optional node?: string | [string, string]

        The node or node pair to focus the grouping on. If not specified, the grouping is applied across all edges in the graph.

    Returns Record<string, InferGraphEdgeEntry<TGraph>[]>

    • A record (object) where each key is a grouping key returned by fn, and its value is an array of edges belonging to that group.

Generated using TypeDoc