GraphColorFlow — a short tutorial

Sasson Margaliot
2 min readJan 11, 2022

A very simple introduction to GraphColorFlow.

Getting Started

Assuming a recent version of Python is alsready installed, you can start useing GraphColorFlow (GCF) , by simpy installing our two libraries:

pip install classidgrpah

pip install graphcolorflow

We can use our first library (classidgrpah) to build a graph representation of our data. We start by deriving a new class from the base class Graph (which is imported from classidgraph). We pass the initial characteristcs of our graph to the base constructor __init__():


from classidgraph.classidgraph import Graph
class OurGraph(Graph):
def __init__(self):
super(OurGraph,self).__init__(num_classes=2, num_features=768)

Now we can construct a directed graph in the memory by calling the methods add_node() and link().

First, lets add four nodes. In GCF, each Node is uniquely identified not by a single string key, but a pair of strings, passed as two parameters: cl (for class) and id (for identifier).


import graphcolorflow.graph
class OurGraph(Graph):
def __init__(self, num_classes = 4,num_features = 3):
super(OurGraph,self).__init__()
...
o = OurGraph()# The nodes for cities
o.add_node("city", "NY")
o.add_node("city", "LA")
o.add_node("city", "London")
o.add_node("city", "Paris")
# The three nodes for countries
o.add_node("country", "US")
o.add_node("country", "UK")
o.add_node("country", "France")

Let’s link cities to contries:


o.link("city", "NY", "country", "US")
o.link("city", "LA", "country", "US")
o.link("city", "London", "country", "UK")
o.link("city", "Paris", "country", "France")

Now each city is linked to the corresponding country. The graph is not connected — it doeen’t have to be.

This way we can enrter whichever directed graph we want.

2. Unsupevidsed Learning

Now we can use our second library (graphcolorflow) to build a complex of Neural Networks. These Networks can then be used for unsupervised learning on our Graph.

=========================

A longer discussion could be found here. An ebook about graphcolorflow is available here.

--

--

Sasson Margaliot

Innovator, Tech Enthusiast, and Strategic Thinker. exploring new frontiers, pushing boundaries, and fostering positive impact through innovation.