Skip to content

Refactor Graph class in SwhUnidirectionalGraph and SwhBidirectionalGraph

This commit is a massive refactor of the project to apply a stronger separation of concerns which will allow the project to be more maintainable and extensible in the future.

The principal change is the switch from a single SwhGraph containing everything SWH-specific to two new classes:

  • SwhUnidirectionalGraph, an ImmutableGraph augmented with SWH-specific methods such as getSWHID(), getNodeType(), etc.

  • SwhBidirectionalGraph, which leverages BidirectionalImmutableGraph to store two SwhUnidirectionnalGraph, one for each direction.

To share common behavior and storage between these two classes, such as handling node types and node properties, another class has been created:

  • SwhGraphProperties, which is designed to contain the graph properties that can apply on the graph whatever its direction is (node types, node properties, dataset version, etc.)

Finally, to allow users of this API to use the two classes interchangeably when the direction(s) do not mattern, both classes implement a new interface:

  • SwhGraph, which is designed to hold the common SWH-specific behavior between SwhUnidirectionalGraph and SwhBidirectionalGraph.
                    ┌──────────────┐
                    │ImmutableGraph◄────────┐
                    └────▲─────────┘        │extends
                         │                  │
                         │       ┌──────────┴────────────────┐
                  extends│       │BidirectionalImmutableGraph│
                         │       └────────────▲──────────────┘
                         │                    │extends
          ┌──────────────┴───────┐     ┌──────┴──────────────┐
          │SwhUnidirectionalGraph│◄────┤SwhBidirectionalGraph│
          └──┬──────────────┬────┘     └────────┬───────────┬┘
             │              │    contains x2    │           │
             │              │                   │           │
             │    implements│                   │implements │
             │             ┌▼──────────┐        │           │
             │             │SwhGraph(I)◄────────┘           │
    contains │             └───────────┘                    │contains
             │                                              │
             │            ┌──────────────────┐              │
             └────────────►SwhGraphProperties◄──────────────┘
                          └──────────────────┘

BidirectionalImmutableGraph is included in this pull-request, but is intended to be merged upstream eventually:

This commit includes a (partial) documentation overhaul. Notably, using cross-dependency compiling of java documentation allows us to remove redundant method documentations when they are inherited from webgraph classes. It also includes cross-dependency linking, which allows users to click on external links to unimi.it libraries.

Finally, this commits introduces stub methods for optionally loading labelled graphs, which will be useful to store edges properties such as file names, etc. To avoid a combinatorial explosion of types (SwhUnidirectionalLabelledGraph, SwhBidirectionalLabelledGraph, etc..), this is only checked at runtime. Classes hold both the unlabelled and labelled versions of the underlying graphs, with the labelled version being equal to null when the labels have not been loaded.

Fixes #2983 (closed)


Migrated from D6953 (view on Phabricator)

Merge request reports