Content Representation With A Twist

Showing posts with label MOM net generation. Show all posts
Showing posts with label MOM net generation. Show all posts

Saturday, May 03, 2008

Generating a basic MOM network

Just for the sake of being able to look up this later. As I am doing this over and over again in several programming languages I apply to get forth with MOM.

I need a graph of at least two distinct layers of nodes (vertices), connected by edges (arcs). The graph may not contain any loops. Therefore I select a number of bottom layer nodes -- the rest is going to be non-bottom layer nodes. For the ease of addressing both kinds of nodes, let's say, the bottom layer nodes have IDs 1..x, the non-bottom layer nodes have ID x+1..n.

To avoid loops, each bottom layer node shall be connected to a non-bottom layer node, each non-bottom layer node shall be connected to a bottom layer node.

Though desirable, this does not imply the result of graph generation will be a single graph: The generation may result in several independent graphs. -- If you are aware of a better approach to get the graph generated, please let me know.

The connectivity of the graph might get improved by randomly adding some further edges. To avoid to cause loops here, the additional edges may be drawn only from non-bottom layer nodes to nodes with a smaller ID, including bottom layer nodes. -- Effectively, this adding of edges may cause the generated graph become multi-leveled.
 

An example for such a mini MOM net generator can be seen below. It's implemented in Pascal (using the GNU Pascal Compiler for compilation) and omits the connectivity increasing step. Though it provides a dump of the generated graph:

program MOMnetGeneration;

const
all_nodes = 50;
bottom_nodes = 2 * all_nodes DIV 5;

type
appropriate_int = shortint;
tEdges = array [1..all_nodes] of appropriate_int;


function rnd(min, max : appropriate_int) : appropriate_int;
begin
rnd := random(max - min) + min;
END;

var
edge : tEdges;
i : appropriate_int;
begin
{ connect bottom to non-bottom nodes: }
for i:=1 to bottom_nodes do
edge [i] := rnd(bottom_nodes+1, all_nodes);

{ connect non-bottom to bottom nodes: }
for i:=bottom_nodes+1 to all_nodes do
edge [i] := rnd(1, bottom_nodes);

{ dump the generated network: }
for i:=1 to all_nodes do
writeln(i, ' -> ', edge [i]);
end.


I compared the speed of Ruby and Pascal for creating 220 31-bit numbers, which took the Pascal compilate about 3 seconds and Ruby between one and two minutes. Therefore, I am back to copiled languages which work close to the hardware. Might try C/C++ as well.

      
Updates:
none so far

Sunday, June 03, 2007

new release: documentation improved, dotty output added

New version is out! It mainly features improved documentation of all of the files of the framework, but also introduced better MOM net output for MOMedgesSet and MOMnet class. For the latter even a simple dotty output method.

See here a sample MOM net created by MOMnet and rendered by dot: Two layer MOM nets oftenly contain hidden, i.e. not explicit (i.e. implicit) content. To have a generator for them available constitutes the chance to develop a detector for such implicit content and to make it explicit. A mechanism that takes both of these steps is known as reorganizsation. -- Which might become implemented next.
      
Updates:
none so far

Friday, May 25, 2007

New version is out!

As before, the version is on gna.org, part of a subversion repository. Quick sum up of the changelog: What changed mostly is MOMnet.rb: Now it is validated and can generate MOM networks.

The option to get MOM networks to be generated relieves the developer to define -- and possibly debug -- MOM networks by his/her own. (I experienced, because of their dual nature -- edges meaning might be given/is given --, MOM networks are harder to debug but pure program code.) Having one -- better: more but one..multiple -- MOM network(s) at hand allows to reorganize the network to make implicit content explicit (marketing speak: "generate new content from yet given one/determine previously unknown content").

Other changes made possible to derive one HomogenousSetDerivatesInfrastructure class from another and inherit the class of the items to be dealed with too. Previously, that class was mentioned in a plain class variable of HomogenousSetDerivatesInfrastructure, which Ruby does not inherit normally. The recent change circumvents that Ruby default behaviour: MOMnet derives from MOMedgesSet, but only the latter becomes initialized to deal with MOMnetEdges only. MOMnet inherits that initialization from MOMnetEdge. -- Previously, there had been a need to tell every derived class explicitly which kind of items it should deal with although a developer would have expected the class to know that because of its anchestry/because its parent was for item class X, hence any child should be like that too. So, the change makes the framework meet that intuitive presumption: Now, children of HomogenousSetDerivatesInfrastructure know the class of the items to deal with.

A minor improvement was to add some output methods to the framework. Additionally, MOMedgesSet now can export to dotty, a graph visualization tool.

Last not least, I extracted changelogs from my local subversion repository for earlier check-ins to the public repository and added them to there too.

      
Updates:
none so far