Commit 53f83f1b authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Add graph-tool examples

parent fcedf9ee
......@@ -28,6 +28,8 @@ import pickle
from flask import Flask, render_template, make_response, redirect, Markup, \
send_file, abort, request, jsonify, url_for
import jinja2_highlight
import process_entry
import analyze
import draw
......@@ -35,7 +37,12 @@ import draw
import numpy
import math
app = Flask(__name__)
class MyFlask(Flask):
jinja_options = dict(Flask.jinja_options)
jinja_options.setdefault('extensions',
[]).append('jinja2_highlight.HighlightExtension')
app = MyFlask(__name__)
access_tokens = set()
if os.path.exists("access_tokens"):
......
.highlight .hll { background-color: #ffffcc }
/* .highlight { background: #ffffff; } */
.highlight .c { color: #888888 } /* Comment */
.highlight .err { color: #FF0000; background-color: #FFAAAA } /* Error */
.highlight .k { color: #008800; font-weight: bold } /* Keyword */
.highlight .o { color: #333333 } /* Operator */
.highlight .ch { color: #888888 } /* Comment.Hashbang */
.highlight .cm { color: #888888 } /* Comment.Multiline */
.highlight .cp { color: #557799 } /* Comment.Preproc */
.highlight .cpf { color: #888888 } /* Comment.PreprocFile */
.highlight .c1 { color: #888888 } /* Comment.Single */
.highlight .cs { color: #cc0000; font-weight: bold } /* Comment.Special */
.highlight .gd { color: #A00000 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gr { color: #FF0000 } /* Generic.Error */
.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.highlight .gi { color: #00A000 } /* Generic.Inserted */
.highlight .go { color: #888888 } /* Generic.Output */
.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.highlight .gt { color: #0044DD } /* Generic.Traceback */
.highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */
.highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */
.highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */
.highlight .kp { color: #003388; font-weight: bold } /* Keyword.Pseudo */
.highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */
.highlight .kt { color: #333399; font-weight: bold } /* Keyword.Type */
.highlight .m { color: #6600EE; font-weight: bold } /* Literal.Number */
.highlight .s { background-color: #fff0f0 } /* Literal.String */
.highlight .na { color: #0000CC } /* Name.Attribute */
.highlight .nb { color: #007020 } /* Name.Builtin */
.highlight .nc { color: #BB0066; font-weight: bold } /* Name.Class */
.highlight .no { color: #003366; font-weight: bold } /* Name.Constant */
.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
.highlight .ni { color: #880000; font-weight: bold } /* Name.Entity */
.highlight .ne { color: #FF0000; font-weight: bold } /* Name.Exception */
.highlight .nf { color: #0066BB; font-weight: bold } /* Name.Function */
.highlight .nl { color: #997700; font-weight: bold } /* Name.Label */
.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
.highlight .nt { color: #007700 } /* Name.Tag */
.highlight .nv { color: #996633 } /* Name.Variable */
.highlight .ow { color: #000000; font-weight: bold } /* Operator.Word */
.highlight .w { color: #bbbbbb } /* Text.Whitespace */
.highlight .mb { color: #6600EE; font-weight: bold } /* Literal.Number.Bin */
.highlight .mf { color: #6600EE; font-weight: bold } /* Literal.Number.Float */
.highlight .mh { color: #005588; font-weight: bold } /* Literal.Number.Hex */
.highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */
.highlight .mo { color: #4400EE; font-weight: bold } /* Literal.Number.Oct */
.highlight .sa { background-color: #fff0f0 } /* Literal.String.Affix */
.highlight .sb { background-color: #fff0f0 } /* Literal.String.Backtick */
.highlight .sc { color: #0044DD } /* Literal.String.Char */
.highlight .dl { background-color: #fff0f0 } /* Literal.String.Delimiter */
.highlight .sd { color: #DD4422 } /* Literal.String.Doc */
.highlight .s2 { background-color: #fff0f0 } /* Literal.String.Double */
.highlight .se { color: #666666; font-weight: bold; background-color: #fff0f0 } /* Literal.String.Escape */
.highlight .sh { background-color: #fff0f0 } /* Literal.String.Heredoc */
.highlight .si { background-color: #eeeeee } /* Literal.String.Interpol */
.highlight .sx { color: #DD2200; background-color: #fff0f0 } /* Literal.String.Other */
.highlight .sr { color: #000000; background-color: #fff0ff } /* Literal.String.Regex */
.highlight .s1 { background-color: #fff0f0 } /* Literal.String.Single */
.highlight .ss { color: #AA6600 } /* Literal.String.Symbol */
.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
.highlight .fm { color: #0066BB; font-weight: bold } /* Name.Function.Magic */
.highlight .vc { color: #336699 } /* Name.Variable.Class */
.highlight .vg { color: #dd7700; font-weight: bold } /* Name.Variable.Global */
.highlight .vi { color: #3333BB } /* Name.Variable.Instance */
.highlight .vm { color: #996633 } /* Name.Variable.Magic */
.highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
......@@ -188,3 +188,11 @@ table.ink-table tr th.tight
.footnote li p:last-child {
margin-bottom: 0
}
.note {
color: #333333
}
.ink-alert.block .highlight {
margin-left: 1.5em;
}
\ No newline at end of file
......@@ -56,7 +56,32 @@ active
examle: <span class="code"><a href="/net/advogato/files/advogato.gt.zst">/net/advogato/files/advogato.gt.zst</a></span>.
</p>
</div>
<div class="ink-alert block info" role="alert">
<h4 style="font-size: larger">Access from <a href="//graph-tool.skewed.de">graph-tool</a></h4>
<p>
This API can also be accessed conveniently from
the <a href="//graph-tool.skewed.de">graph-tool</a> library.
</p>
<p>A dictionary corresponding to a particular dataset is obtained via:
{% highlight 'python' %}
import graph_tool.all as gt
gt.collection.ns_info["advogato"]
{% endhighlight %}
<p>Individual networks can be downloaded via:
{% highlight 'python' %}
g = gt.collection.ns["advogato"]
{% endhighlight %}</p>
<p>For datasets with multiple networks, the dictionary accepts either a slash separator or a tuple:
{% highlight 'python' %}
g = gt.collection.ns["fresh_webs/AkatoreA"]
# or equivalently:
g = gt.collection.ns[("fresh_webs", "AkatoreA")]
{% endhighlight %}</p>
</div>
</div>
</div>
......
......@@ -25,6 +25,7 @@
<link rel="stylesheet" type="text/css" href="/static/ink/css/ink.css">
<link rel="stylesheet" type="text/css" href="/static/ink/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="/static/css/custom.css">
<link rel="stylesheet" type="text/css" href="/static/css/code.css">
<link href='//fonts.googleapis.com/css?family=Droid+Sans|Droid+Sans+Mono|Droid+Serif:400,400italic,700,700italic' rel='stylesheet' type='text/css'>
<!--[if IE 7 ]>
......
......@@ -16,6 +16,29 @@ active
You may also take a look at the <a href="https://git.skewed.de/count0/netzschleuder/-/blob/master/entries/{{entry.name}}/__init__.py">source code</a>.
</blockquote>
</div>
<div class="all-25" style="float:right; clear:right; vertical-align:top; display:inline">
<blockquote class="note">
The
{% if entry.files[0][1] is none %}
network
{% else %}
networks
{% endif %}
in this dataset can be loaded directly
from <a href="https://graph-tool.skewed.de">graph-tool</a> with:
{% highlight 'python' %}
import graph_tool.all as gt
{% if entry.files[0][1] is none -%}
g = gt.collection.ns["{{entry.name}}"]
{%- else -%}
g = gt.collection.ns["{{entry.name}}/{{entry.files[0][1]}}"]
{%- endif -%}
{% endhighlight %}
{% if entry.files[0][1] is not none %}
(and likewise for the other networks available.)
{% endif %}
</blockquote>
</div>
<h1 style="margin-top: 0px"><a href="/net/{{entry.name}}" class="mono">{{entry.name}}</a> &mdash; {{entry.title}}
</h1>
<dl>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment