473,378 Members | 1,280 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

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<region*> 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<region*> m_neighbors;
P m_property;
};
std::vector<region*> m_regions;
};
Jul 23 '05 #1
0 7044

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

Similar topics

2
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...
67
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...
12
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 ...
0
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
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...
1
by: madhuparna | last post by:
Plzz give the code for implementing adjacency matrix in C
7
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
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.