GraphCodec

scalax.collection.io.jsoniter.nonlabeled.GraphCodec
object GraphCodec

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
GraphCodec.type

Members list

Type members

Inherited and Abstract classlikes

abstract protected class IdBasedDecoder[N, E <: Edge[N], G <: ([X, Y <: Edge[X]] =>> AnyGraph[X, Y]), ER, Id <: AnyVal | String](id: N => Id, factory: (Iterable[N], Iterable[E], GraphConfig) => G[N, E], default: G[N, E], config: GraphConfig, in: JsonReader)(using nodeCodec: JsonValueCodec[N], edgeCodec: JsonValueCodec[ER])

Attributes

Inherited from:
IdBasedGraphCodec (hidden)
Supertypes
class Object
trait Matchable
class Any

Value members

Concrete methods

def withNodeReferences[N <: AnyRef, E <: Edge[N], G <: ([X, Y <: Edge[X]] =>> AnyGraph[X, Y]), Id <: AnyVal | String, ER <: WithNodeReferences[Id] : ClassTag](id: N => Id, withNodeReferences: (E, N => Id) => ER, factory: (Iterable[N], Iterable[E], GraphConfig) => G[N, E], config: GraphConfig, onJsonNull: => G[N, E], edgeFactory: Option[PartialFunction[(String, N, N), E]], diHyperEdgeFactory: Option[PartialFunction[(String, OneOrMore[N], OneOrMore[N]), E]], hyperEdgeFactory: Option[PartialFunction[(String, Several[N]), E]])(implicit evidence$1: ClassTag[ER], nodeCodec: JsonValueCodec[N], idCodec: JsonValueCodec[Id], edgeWithNodeReferencesCodec: JsonValueCodec[ER], exclude: NotGiven[E <:< SingleLabel[_]]): JsonValueCodec[G[N, E]]

Produces a codec for a Graph with non-labeled edges where JSON edge ends are represented by node IDs.

Produces a codec for a Graph with non-labeled edges where JSON edge ends are represented by node IDs.

Replacing edge ends by node IDs facilitates a more compact JSON representation. This is because nodes are encoded into an array of nodes so edges, that get encoded into a separate array, do not need to also embed complete nodes. Therefore, prefer this Graph codec over embedded nodes unless nodes are of some primitive-like type.

For edges, this codec uses the predefined ADT WithNodeReferences which is an intermediate JSON representation of edges with edge ends of type N replaced by node IDs of type Id.

Type parameters

E

the type of edges.

ER

the type of the JSON representation of edges with edge ends of type Id.

G

the type of Graph.

Id

the type of node IDs constrained to primitive-like types.

N

the type of nodes.

Value parameters

config

to be passed to the Graph after JSON decoding. Use GraphCodec.graphConfig to produce your best-guess configuration.

diHyperEdgeFactory

to produce directed hyperedges from JSON. Provide separate cases for all used directed hyperedge types.

edgeFactory

to produce edges from JSON. Provide separate cases for all used edge types. The first, String member of the tuple corresponds to the edgeT parameter of the intermediate *WithNodeReferences class.

edgeWithNodeReferencesCodec

codec for the intermediate JSON edge type ER. Use JsonCodecMaker.make to create this codec. In case you are using one of the ADTs Any*WithNodeReferences, the JSON will also include the concrete type like "type": "DiEdgeWithNodeReferences". You can replace these verbose class names by shortcuts by invoking the macro like JsonCodecMaker.make(compactClassNames).

exclude

causes a compile error if edges have the superclass SingleLabel. Note that this is just a partial check since there exists no ultimate library abstraction for labeled classes.

factory

to create the Graph from the decoded JSON based on Iterables of nodes and edges. Typically, you can pass Graph.from(_, _)(_) where Graph is either mutable or immutable.

hyperEdgeFactory

to produce hyperedges from JSON. Provide separate cases for all used hyperedge types.

id

a one-to-one function producing an ID for a given node.

idCodec

codec for Id.

nodeCodec

codec for N.

onJsonNull

is used in case the complete JSON is null. Either supply a default, usually empty, Graph or null.asInstanceOf[...] to let the null case fail. See also JsonValueCodec.nullValue

withNodeReferences

factory for the JSON representation of edges. Just supply the appropriate predefined factory like DiEdgeWithNodeReferences.apply. The predefined factories also support mixed Graphs.

Attributes

Inherited methods

def graphConfig(orderHint: Int, degreeHint: Int): GraphConfig

Produces an optimal Graph configuration for the purpose of reducing internal memory allocations.

Produces an optimal Graph configuration for the purpose of reducing internal memory allocations.

Value parameters

degreeHint

edge degree with a high percentile.

orderHint

number of nodes in the Graph with a high percentile.

Attributes

Inherited from:
GraphCodec (hidden)

Inherited fields

val Edges: String

The key of the array of edges in the JSON.

The key of the array of edges in the JSON.

Attributes

Inherited from:
GraphCodec (hidden)
val Nodes: String

The key of the array of nodes in the JSON.

The key of the array of nodes in the JSON.

Attributes

Inherited from:
GraphCodec (hidden)