fslaborg / Graphoscope

A pragmatic approach to network science.
http://fslab.org/Graphoscope/
MIT License
14 stars 6 forks source link

Implement "copy" functionality for FGraph #52

Open DoganCK opened 1 year ago

DoganCK commented 1 year ago

Description Our ultimate goal is to leave the decision to use mutation or not to the user. Mutation makes sense for heavy duty operations that run on the cloud. But while developing and working with smaller graphs mutation gets in the way and can be unwieldy to use. The initial step for this is to have a deep copy functionality.

Pointers https://learn.microsoft.com/en-us/dotnet/api/system.object.memberwiseclone?view=net-7.0

timu commented 1 year ago

I'll be working on this one

timu commented 1 year ago

The implementation is a shared effort from myself and @yigitl.

We now have an implementation that creates clones of undirected graphs.

Currently, the function will create a deep copy if the NodeData/EdgeData generics are value types, and it will create a shallow copy if these are reference types.

This implementation should be revised after a decision on how to handle EdgeData/NodeData generics. There are three ways of handling these generics:

  1. Enforce IClonable, so that the user has to use data types that implement _.Clone(), or implement _.Clone() for their own data types.
  2. Constraint these generics to be value types. This means that records should have [<Struct>] flag.
  3. Do nothing, just tell the user is cloning might not work if the generics are reference types.

Implementation of these options is relatively trivial and can be applied as soon as a decision has been reached.