473,569 Members | 2,400 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adjacency list representation

I need some help to implement the adjacency list representation of a
(undirected) graph. The data structure I need is something like the
picture on the website http://www.pagebox.net/graph.html#toc3.

Basically, I want the vertices in the graph to represent regions of
pixels in a 2D image. And the edges denotes adjacent regions. I need
this data structure to implement a region merging segmentation
algorithm. The graph will be constructed from 'scanning' an image where
a pixel value is the region label.

Each region should have some basic properties:

class region {
std::size_t m_label; // Unique label
std::list<point > m_pixels; // Pixel coordinates (x,y)
};

But every variant of the segmentation algorithms will need some
additional (statistical) properties. These parameters are calculated
from the corresponding pixels inside the region and one (or two) other
images (not the one with the labels).

class region_a : public region {
... // Properties for regions of type a
};
class region_b : public region {
... // Properties for regions of type b
};

The actual properties are not important and are only used for comparing
two regions (and of course in the construction phase). So I can add this
functionallity in the base class as a virtual function, and override it
in the derived classes.

The basic structure should have the same functionality for all types of
regions, like accessing adjacent regions, merging two small regions in a
new larger region, ... And this is where I'm having trouble. I tried
some different implementations (see below) but they don't offer the
flexibility I want. The problem is often the m_neighbors member. Any
suggestions are welcome.

// METHOD 1:

template <class R>
class region {
public:
std::size_t m_label;
std::list<point > m_pixels;
std::list<regio n*> m_neighbors;
};
template <class R>
class rag {
public:
std::vector<R*> m_regions;
};

class region_a : public region<region_a > {
...
};
class rag_a : public rag<region_a> {
...
};

METHOD 2:

template <typename P>
class rag {
public:
class region {
public:
std::size_t m_label;
std::list<point > m_pixels;
std::list<regio n*> m_neighbors;
P m_property;
};
std::vector<reg ion*> m_regions;
};
Jul 23 '05 #1
0 7054

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3746
by: Oleg Ogurok | last post by:
Hi all, I'm looking for a fast algorithm to do the following: A DataTable has the following columns: ID, ParentID, Title, Body, etc. It represents webforum conversation threads. ParentID points to the ID of the parent post. I'm trying to convert this into a tree structure in memory (e.g. XML). I understand this can be done with recursion...
67
6251
by: Philippe Martin | last post by:
Hi, I'm looking for an algo that would convert a list such as: I'm using python to prototype the algo: this will move to C in an embedded system where an int has 16 bits - I do not wish to use any python library. l1 = #represents the decimal number 12345678 l2 = func (l1) # l2 = #represents 0x12D687
12
5798
by: Steve | last post by:
I have been studying the Adjacency List Model as a means of achieving a folder structure in a project I am working on. Started with the excellent article by Gijs Van Tulder http://www.sitepoint.com/article/hierarchical-data-database My database has this basic structure: Id FolderName
0
1140
by: amodagni | last post by:
Hi ! Could someone please guide me to SQL code required for managing data in tables in which hierarchical data stored in adjacency or Nested set model.
2
7646
by: sanjeevron | last post by:
Define a class for an adjacency matrix representation of weighted, directed graphs in C++. 2. Implement the following essential methods in your class. Any input validation or exceptions must be handled within the methods. • addNode - adds a new node (vertex) to the graph • deleteNode(i) - deletes a given node, i from the graph •...
1
3100
by: madhuparna | last post by:
Plzz give the code for implementing adjacency matrix in C
7
9200
thatos
by: thatos | last post by:
Here is the EdgeList class class Graph { protected int numvertices; protected int numedges; protected boolean directed; protected EdgeList adjlist ; // Constructors
2
9415
by: orzeech | last post by:
Here's my code that's supposed to be a basic graph implementation using adjacency lists. It comes straight from R.Sedgewick's "Algorithms in C++". However "23 - ISO C++ forbids declaration of `vector' with no type ". Why is that? class graf { struct edge
0
2314
by: kantai | last post by:
Need help in solving the problem below. Any help would be highly appreciated Implement the adt graph as a C++ class first by using an adjacency matrix to represent the graph then by using an adjacency list to represent the graph. Extend the programming problem by adding adt operations such as Isconnected and HasCycle. also include...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2117
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
946
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.