+ All Categories
Home > Documents > YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords:...

YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords:...

Date post: 16-Aug-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
34
YAGS Y A G S C. Cedio 1 R. MacKinney-Romero 2 M.A. Pizaña 3 I.A. Robes 4 R. Viarroe-Fores 5 1,2,3,4 Universidad Autónoma Metropoitana. 5 Universidad Autónoma de Estado de Hidago
Transcript
Page 1: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

YAGSYET ANOTHER GRAPH SYSTEM

C. Cedillo1 R. MacKinney-Romero2 M.A. Pizaña3

I.A. Robles4 R. Villarroel-Flores5

1,2,3,4Universidad Autónoma Metropolitana.5Universidad Autónoma del Estado de Hidalgo

Page 2: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Overview

1. Introduction

2. Graph operations

3. Morphisms of graphs

4. Backtracking

1

Page 3: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

INTRODUCTION

Page 4: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

About YAGS

# YAGS offers a graph-drawing subsystem, methods fordealing with graph homomorphism and a genericbacktracking subsystem.

# YAGS was initiated by M.A. Pizaña in May 2003, and thenincorporated the work of R. MacKinney-Romero, R.Villarroel-Flores, C. Cedillo and I.A. Robles.

# It is a GAP package: https://www.gap-system.org/.# It is available at: http://xamanek.izt.uam.mx/yags/.# It’s free! (GNU General Public License 3).

3

Page 5: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

About YAGS

# YAGS offers a graph-drawing subsystem, methods fordealing with graph homomorphism and a genericbacktracking subsystem.

# YAGS was initiated by M.A. Pizaña in May 2003, and thenincorporated the work of R. MacKinney-Romero, R.Villarroel-Flores, C. Cedillo and I.A. Robles.

# It is a GAP package: https://www.gap-system.org/.

# It is available at: http://xamanek.izt.uam.mx/yags/.# It’s free! (GNU General Public License 3).

3

Page 6: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

About YAGS

# YAGS offers a graph-drawing subsystem, methods fordealing with graph homomorphism and a genericbacktracking subsystem.

# YAGS was initiated by M.A. Pizaña in May 2003, and thenincorporated the work of R. MacKinney-Romero, R.Villarroel-Flores, C. Cedillo and I.A. Robles.

# It is a GAP package: https://www.gap-system.org/.# It is available at: http://xamanek.izt.uam.mx/yags/.

# It’s free! (GNU General Public License 3).

3

Page 7: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

About YAGS

# YAGS offers a graph-drawing subsystem, methods fordealing with graph homomorphism and a genericbacktracking subsystem.

# YAGS was initiated by M.A. Pizaña in May 2003, and thenincorporated the work of R. MacKinney-Romero, R.Villarroel-Flores, C. Cedillo and I.A. Robles.

# It is a GAP package: https://www.gap-system.org/.# It is available at: http://xamanek.izt.uam.mx/yags/.# It’s free! (GNU General Public License 3).

3

Page 8: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Getting Started

Load YAGS/home/joe/Yags> gap

--- some GAP info here ---gap> RequirePackage("yags");

Loading YAGS - Yet Another Graph System, Version 0.0.3.Copyright (C) 2016 by the YAGS authors; for details type: ?yags:authorsThis is free software under GPLv3; for details type: ?yags:copyright

true

gap>

4

Page 9: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Define and draw a graph

Define a graph (by edges)gap>g:=GraphByEdges([[1, 2], [2, 3], [3, 4], [4, 1], [1, 5], [5, 4]]);

Draw a graphgap> Draw(g);

5

Page 10: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Define and draw a graph

Define a graph (by walks)gap> g:=GraphByWalks([1, 2, 3, 4, 1], [1, 4, 5, 1]);

Draw a graphgap> Draw(g);

6

Page 11: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Graph Category

gap> g:=GraphByWalks([1, 2, 3, 4, 1], [1, 4, 5, 1]);Graph( Category := SimpleGraphs, Order := 5, Size :=

6, Adjacencies := [ [ 2, 4, 5 ], [ 1, 3 ], [ 2, 4 ], [

1, 3, 5 ], [ 1, 4 ] ] )

7

Page 12: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Graph Categories

# Graphs: May contain loops, arrows and edges.# UndirectedGraphs: Can not contain plain arrows (only

edges and loops).# LooplessGraphs: Can not contain loops (only arrows and

edges).# OrientedGraphs:Can not contain edges nor loops (only

arrows).# SimpleGraphs: Can not contain loops nor arrows (only

edges).

8

Page 13: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Graph Category (example)

SetDefaultGraphCategorygap> SetDefaultGraphCategory(Graphs);

gap> CompleteGraph(4);

Graph( Category := Graphs, Order := 4, Size := 16,

Adjacencies := [ [ 1, 2, 3, 4 ], [ 1, 2, 3, 4 ], [ 1,

2, 3, 4 ], [ 1, 2, 3, 4 ] ] )

gap>SetDefaultGraphCategory(SimpleGraphs);gap>CompleteGraph(4);Graph( Category := SimpleGraphs, Order := 4, Size := 6,

Adjacencies := [ [ 2, 3, 4 ], [ 1, 3, 4 ], [ 1, 2, 4 ],

[ 1, 2, 3 ] ] )

9

Page 14: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Command completition

TAB key for command completition:

10

Page 15: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Command completition and online help

Typing GraphBy<TAB><TAB> in the command line shows:

# GraphByAdjMatrix# GraphByAdjacencies# GraphByCompleteCover# GraphByEdges# GraphByRelation# GraphByWalks

You can always access the online help by typing:?yags:GraphByWalks

11

Page 16: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

GRAPH OPERATIONS

Page 17: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Induced subgraph

Define a graph (induced subgraph)gap> h:=InducedSubgraph(g,[1,4,5]);

Draw(g) Draw(h)

13

Page 18: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Intersection Graph

Define a graph (intersection graph)gap> g:=IntersectionGraph([[1,2,3],[3,4,5],[5,6,7]]);

Draw a graphgap> Draw(g);

14

Page 19: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Properties of a graph

For the previous graph:

Command Result

MaxDegree(g) 3

MinDegree(g) 2

Diameter(g) 2

Girth(g) 3

NumberOfCliques(g) 4

NumberOfConnectedComponents(g) 1

Also:VertexDegree(g,v), Distance(g,x,y), Eccentricity(g,x),

Radius(g), InNeigh(G, x), ...15

Page 20: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Graph families

Command Graph

PathGraph(5) P5

CycleGraph(5) C5

CompleteGraph(5) K5

DiscreteGraph(5) K5

CompleteBipartiteGraph(3, 3) K3,3

OctahedralGraph(5) O5

Also:Circulant(n,J), CompleteBipartiteGraph(n,m),

CubeGraph(n), CompleteMultipartiteGraph(n1,n2[, n3

...]), TorusGraph(n,m), WheelGraph(n), FanGraph(n),

SunGraph(n), SpikyGraph(n), ...16

Page 21: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Products (Cartesian Product)

Cartesian product g�hgap> g:=PathGraph(3);gap> h:=PathGraph(3);gap> p:=BoxProduct(g,h);

gap> Draw(p);

17

Page 22: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Products

Command Result

TimesProduct(g,h) Direct product g × hBoxProduct(g,h) Cartesian product g�hBoxTimesProduct(g,h) Strong product g � hJoin(g,h) Zykov sum g + hDisjointUnion(g,h) Disjoint uniong ∪ h

18

Page 23: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Graphs of given order

It is possible to return a list of all graphs of order n (up toisomorphism).This operation uses Brendan McKay’s data:https://cs.anu.edu.au/people/Brendan.McKay/data/graphs.html.

Graphs of given order (n ≤ 9)gap> GraphsOfGivenOrder(2);

[ Graph( Category := SimpleGraphs, Order := 2, Size :=

0, Adjacencies := [ [ ], [ ] ] ),

Graph( Category := SimpleGraphs, Order := 2, Size :=

1, Adjacencies := [ [ 2 ], [ 1 ] ] ) ]

gap> Length(GraphsOfGivenOrder(9));

274668

19

Page 24: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Graphs of given order (filtered list)

Graphs of given order (n ≤ 9)gap> l:=GraphsOfGivenOrder(6);;

gap> f:=Filtered(l,g->Girth(g)=3);;

20

Page 25: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Random graphs

Statistics for random graphsgap> GraphAttributeStatistics(10, 1/2, Diameter);[[2, 34], [3, 59], [4, 5], [5, 1], [in f init y , 1]]

Statistics for random graphs (boolean value)gap> GraphAttributeStatistics(10, 1/2, IsCliqueHelly);32

gap> GraphAttributeStatistics(10, 1/10 ∗ [1..9], IsCliqueHelly);[100, 100, 94, 63, 34, 16, 30, 76, 95]

21

Page 26: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

MORPHISMS OF GRAPHS

Page 27: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Morphisms of Graphs

Full mono morphismsgap> p3:=PathGraph(3);

gap> c4:=CycleGraph(4);

gap> FullMonoMorphism(p3,c4);

[1, 2, 3]gap> FullMonoMorphisms(p3,c4);

[[1, 2, 3], [1, 4, 3], [2, 1, 4], [2, 3, 4], [3, 2, 1],[3, 4, 1], [4, 1, 2], [4, 3, 2]]

23

Page 28: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Morphism of graphs (example)

Examplegap> IsInducedSubgraph:=function(h , g)> return FullMonoMorphism(h , g)<>fail; end;

function( h, g ) ... end

gap>IsInducedSubgraph(PathGraph(3),CycleGraph(4));true

24

Page 29: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Morphism of graphs (fragments)

# Morphism: The images of adjacent vertices are adjacent.# Epi: The morphism is vertex-surjective.# Mono: The morphism is vertex-injective.# Bi: The morphism is vertex-bijective.# Metric: The image of any pair of vertices are at the same

distance from each other as the original pair of vertices.# Full:

f (x) f (y) ∈ E(H) ⇒ ∃x′y′ ∈ E(G)with f (x′y′) � f (x) f (y).

25

Page 30: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

BACKTRACKING

Page 31: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Example: proper colorings

27

Page 32: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Example: proper colorings

A coloring is a function f : {1, 2, 3} ⇒ {r, b}

start

r

r,r

r,r,r r,r,b

r,b

r,b,r r,b,b

b

b,r

b,r,r b,r,b

b,b

b,b,r b,b,b

28

Page 33: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Backtracking (example)

Examplegap> g:=PathGraph(3);;

gap> chk:=function(L,g)

> local x,y;

> if L=[] then return true; fi;

> x:=Length(L);

> for y in [1..x-1] do

> if IsEdge(g,[x,y]) and L[x]=L[y] then

> return false;

> fi;

> od;

> return true;

> end;

function( L, g ) ... end

gap> BacktrackBag(["r","a"],chk,Order(g),g);

[ [ "r", "b", "r" ], [ "b", "r", "b" ] ] 29

Page 34: YAGS - Yet Another Graph Systemxamanek.izt.uam.mx/coloquio/2017/CVNL2017.pdf · Beamer Keywords: Beamer theme, sthlm Created Date: 3/8/2017 8:29:27 AM ...

Questions?


Recommended