Skip to content
Daria-Maltseva edited this page Nov 5, 2018 · 4 revisions

Downloaded Python files from GitHub Nets, put to the C:\Nets (Daria`s computer).

>>> gdir = 'C:/Nets'
>>> import sys, os, datetime
>>> sys.path = [gdir]+sys.path
>>> from TQ import *
>>> TQ.report()
semiring = combinatorial
add = add
mult = mul
sZero = 0
sOne = 1
...
>>> TQ.sAdd(3,4)
7
>>> TQ.sMul(3,4)
12
>>> TQ.path()
>>> TQ.report()
semiring = path
add = min
mult = add
sZero = inf
sOne = 0
...
>>> TQ.sAdd(3,4)
3
>>> TQ.sMul(3,4)
7
>>>

Then

a = [(1, 5, 2), (6, 8, 1), (11, 12, 3), (14, 16, 2),
(17, 18, 5), (19, 20, 1)]
b = [(2, 3, 4), (4, 7, 3), (9, 10, 2), (13, 15, 5), (16, 21, 1)]

TQ.combinatorial()
>>> s = TQ.sum(a,b)
>>> s
[(1, 2, 2), (2, 3, 6), (3, 4, 2), (4, 5, 5), (5, 6, 3), (6, 7, 4),
(7, 8, 1), (9, 10, 2), (11, 12, 3), (13, 14, 5), (14, 15, 7), (15, 16, (16, 17, 1), (17, 18, 6), (18, 19, 1), (19, 20, 2), (20, 21, 1)]
>>> p = TQ.prod(a,b)
>>> p
[(2, 3, 8), (4, 5, 6), (6, 7, 3), (14, 15, 10), (17, 18, 5), (19, 20, 1)]
>>> TQ.TqSummary(s)
(1, 21, 1, 7)
>>> TQ.TqSummary(p)
(2, 20, 1, 10)

We had to copy the files d3.v3.min.js and barData.js to Charts folder (C:\Mail.Ru Cloud\ANR HSE\ANR Projects\SNA Vlado Batagelj\Final\Temporal analysis\Charts), and then (because I have an association between html and TextPad) we changed the extension of TQchart from "html" to "htm" (usually it is not needed).

Opened Nets (C:\Nets), found TQshow, and changed "html" in the following command as "htm".

b.open(cdir+'/TQchart.htm')

Final code

>>> gdir = 'C:/Nets'
>>> import sys, os, datetime
>>> sys.path = [gdir]+sys.path
>>> from TQ import *
>>> from Nets import Network as N
>>> a = [(1, 5, 2), (6, 8, 1), (11, 12, 3), (14, 16, 2),
(17, 18, 5), (19, 20, 1)]
>>> b = [(2, 3, 4), (4, 7, 3), (9, 10, 2), (13, 15, 5), (16, 21, 1)]
>>> s = TQ.sum(a,b)
>>> s
[(1, 2, 2), (2, 3, 6), (3, 4, 2), (4, 5, 5), (5, 6, 3), (6, 7, 4), (7, 8, 1), (9, 10, 2), (11, 12, 3), (13, 14, 5), (14, 15, 7), (15, 16, 2), (16, 17, 1), (17, 18, 6), (18, 19, 1), (19, 20, 2), (20, 21, 1)]
>>> cdir = 'C:/Mail.Ru Cloud/ANR HSE/ANR Projects/SNA Vlado Batagelj/Final/Temporal analysis/Charts'
>>> TQmax = 12; Tmin = 0; Tmax = 21; w = 600; h = 180
>>> tit = 'temporal sum'
>>> N.TQshow(s,cdir,TQmax,Tmin,Tmax,w,h,tit,fill='red')

Exporting pictures

The procedure Graph.TQshow displays a given TQ using the Chrome web browser. The picture can be saved either as a bitmap or as an SVG le.

  1. Bitmap
    Use Irfanview.
    Make PrtSc of the Pic in browser, and insert it to the Irfanview, then select what is needed - edit - crop selection. Save as png. file.

  2. SVG
    To do the later activate in Chrome

Tools/More tools/Developer tools (Дополнительные настройки - Инструменты разработчика - Elements). 

Select the line with the tag and right click on it. Select the option

Copy/Copy element    

and open a text editor (TextPad). Paste the element and save as an SVG.le.
Using Inkscape or some other vector graphics editor you can convert it to PDF (Файл - Свойства документа - Подогнать размер страницы под содержимое / Сохранить как pdf).