Graph Motion

This is implementation of motions of a graph.

AUTHORS:

  • Jan Legerský (2019-01-24): initial version
  • Jan Legerský (2020-03-12): update to SageMath 9.0

Classes

class flexrilog.graph_motion.GraphMotion(graph)[source]

Bases: sage.structure.sage_object.SageObject

classmethod CnSymmetricGridConstruction(G, delta, a_base=[], b_base=[])[source]
classmethod Deltoid(par_type='rational')[source]

Return a deltoid motion.

classmethod GridConstruction(graph, NAC_coloring, zigzag=False, check=True, red_components_ordered=[], blue_components_ordered=[])[source]

Return the motion obtained by grid construction for given NAC-coloring.

classmethod ParametricMotion(graph, parametrization, par_type, active_NACs=None, sampling_type=None, interval=None, check=True)[source]

Return parametric motion of a graph with a given parametrization.

INPUT:

  • graph – an instance of FlexRiGraph
  • parametrization – a dictionary with a key being a vertex of the graph and its value being the position given as a vector.
  • par_type – type of the parametrization: rational or symbolic
classmethod SpatialEmbeddingConstruction(graph, active_NACs, check=True, four_cycle_motion=None, vertex_at_origin=None, subs_dict={})[source]

Return a motion given by spatial embedding construction.

INPUT:

animation_SVG(realizations, fileName='', edge_partition=True, first=None, totalTime=12, width=500, repetitions='indefinite', radius='default', return_IPythonSVG=True, flipY=True, rel_margin=0.1, colors=[], rnd_str=True, vertex_labels=True)[source]

Save an SVG animation.

EXAMPLES:

sage: from flexrilog import GraphGenerator, GraphMotion
sage: G = GraphGenerator.ThreePrismGraph()
sage: delta = G.NAC_colorings()[0]
sage: M = GraphMotion.GridConstruction(G, delta.conjugated(), zigzag=[[[0,0], [0,1]], [[0,0], [3/4,1/2], [2,0]]])
sage: M.animation_SVG()
<IPython.core.display.SVG object>

TODO:

Doc, examples

height_function(vertex_edge_collisions, extra_layers=0, edge_edge_collisions=[])[source]

Return a height function of edges if possible for given vertex-edge collisions.

WARNING:

Costly, since it runs through all edge-colorings.

class flexrilog.graph_motion.ParametricGraphMotion(graph, input_format, active_NACs, data, check)[source]

Bases: flexrilog.graph_motion.GraphMotion

animation_SVG(fileName='', edge_partition=True, first=None, totalTime=12, width=500, repetitions='indefinite', radius='default', return_IPythonSVG=True, fps=25, flipY=True, rel_margin=0.1, colors=[], rnd_str=True, vertex_labels=True)[source]

Save an SVG animation.

EXAMPLES:

sage: from flexrilog import GraphGenerator, GraphMotion
sage: G = GraphGenerator.ThreePrismGraph()
sage: delta = G.NAC_colorings()[0]
sage: M = GraphMotion.GridConstruction(G, delta.conjugated(), zigzag=[[[0,0], [0,1]], [[0,0], [3/4,1/2], [2,0]]])
sage: M.animation_SVG()
<IPython.core.display.SVG object>

TODO:

Doc, examples

collisions()[source]

Return vertex-edge collisions.

OUTPUT:

A dictionary where key v is a vertex and the corresponding value is a list of edges e such that v collides with e for some parameter value.

EXAMPLES:

sage: from flexrilog import GraphMotion
sage: GraphMotion.Deltoid().collisions()
{0: [(1, 2), (2, 3)], 1: [(0, 3), (2, 3)], 3: [(0, 1), (1, 2)]}
sage: from flexrilog import FlexRiGraph
sage: t = var('t')
sage: edges = [(1, 4), (1, 5), (1, 6), (2, 4), (2, 5), (2, 6), (3, 5), (3, 6), (3, 4)]
sage: M = GraphMotion.ParametricMotion(FlexRiGraph(edges),
....:     {1: vector([sin(t),0]), 2: vector([sqrt(1+sin(t)^2),0]), 3: vector([-sqrt(2+sin(t)^2),0]),
....:     4: vector([0,cos(t)]), 5: vector([0,sqrt(1+cos(t)*cos(t))]), 6: vector([0,-sqrt(2+cos(t)^2)])},
....:     'symbolic')
sage: M.collisions()
{1: [(3, 4), (2, 4)], 4: [(1, 5), (1, 6)]}

WARNING:

It is not guaranteed that all collisions are found, since it depends on numerical root finding of complicated expressions.

edge_lengths()[source]

Return the dictionary of edge lengths.

fix_edge(edge, check=True)[source]

Change the fixed edge in the motion.

generate_POVray(filename, height_function, antialias=True, frames=200, width=1024, height=768, labels=False, camera_location=[3.0, 3.0, 3.0], look_at=[0.0, 0.3, 0.0], compile_animation=False)[source]

Generate files for POV-ray animation.

TODO:

description, make radius as parameter

merge_animations(motions, total_time=12, fps=25, **kwargs)[source]

Return an animation by concatenating a list of motions.

parametrization()[source]

Return the parametrization.

TODO:

Doc, examples

realization(value, numeric=False)[source]

Return the realization for given value of the parameter.

TODO:

Doc, examples

sample_motion(N, numeric=True, start_margin=0, end_margin=0)[source]

Return a sampling of the motion.

TODO:

Doc, examples