473,394 Members | 1,718 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,394 software developers and data experts.

how to implement a huge adjacent matrix?

Hi everyone
Now i'm designing a random instances generator for maximum clique
problem using C.
So I planing to implement a adjacent matrix in this generator to store
the whole graph going to be generated. I couldn't find a method other
than using an unsigned char[][], but in this way, 7 bits in a unsigned
char will be wasted. Could anyone teach me a more effective way to
implement it? Thank you!

Mar 15 '06 #1
2 2451
On Wednesday 15 March 2006 06:40, lu**********@gmail.com opined (in
<11**********************@u72g2000cwu.googlegroups .com>):
Hi everyone
Now i'm designing a random instances generator for maximum clique
problem using C.
So I planing to implement a adjacent matrix in this generator to store
the whole graph going to be generated. I couldn't find a method other
than using an unsigned char[][], but in this way, 7 bits in a
unsigned char will be wasted. Could anyone teach me a more effective
way to implement it? Thank you!


If I understand your problem correctly, you actually want an /adjacency/
matrix which, if memory serves is just a 0/1 matrix. So, it seems you
want to pack your bits, instead of using a whole `char` for each one.
You can still use the same sort of matrix you say you have now, just
pack your bits into it's elements. To make this as portable as
possible, do not assume, say, 8 bits, but use CHAR_BIT defined in
<limits.h> to tell you the size of `char` on your system. This will be
more work, so you will lose some performance extracting and packing
bits, but not too much.

--
BR, Vladimir

There's small choice in rotten apples.
-- William Shakespeare, "The Taming of the Shrew"

Mar 15 '06 #2
"Vladimir S. Oka" <no****@btopenworld.com> writes:
On Wednesday 15 March 2006 06:40, lu**********@gmail.com opined (in
<11**********************@u72g2000cwu.googlegroups .com>):
Hi everyone
Now i'm designing a random instances generator for maximum clique
problem using C.
So I planing to implement a adjacent matrix in this generator to store
the whole graph going to be generated. I couldn't find a method other
than using an unsigned char[][], but in this way, 7 bits in a
unsigned char will be wasted. Could anyone teach me a more effective
way to implement it? Thank you!


If I understand your problem correctly, you actually want an /adjacency/
matrix which, if memory serves is just a 0/1 matrix. So, it seems you
want to pack your bits, instead of using a whole `char` for each one.
You can still use the same sort of matrix you say you have now, just
pack your bits into it's elements. To make this as portable as
possible, do not assume, say, 8 bits, but use CHAR_BIT defined in
<limits.h> to tell you the size of `char` on your system. This will be
more work, so you will lose some performance extracting and packing
bits, but not too much.


And use unsigned char, not plain char (which can be either signed or
unsigned).

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 15 '06 #3

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

Similar topics

6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
5
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more...
4
by: fivelitermustang | last post by:
Essentially what the program needs to do is split apart a large group of data and then it further splits apart the groups of data, etc... For example, Level 0 starts off with a large array data....
3
by: sdisalvo | last post by:
I'm looking for a way to filter records in a query (or report) based on a value in a field of an adjacent record. Can this be done easily? I cannot find any info in the help files. Thanks
15
by: luke.yolanda | last post by:
hi everyone I have a question. First, I have implemented a huge matrix in a program, like 'unsigned char matrix;', when I executed this program, the error occured. Then I modified the ...
15
by: pkirk25 | last post by:
I have a file with roughly 1000 lines that I cannot allow the user to read but which I want to use in my project. I thought I could copy it into one huge string variable but that won't work...
10
by: Bernhard Reinhardt | last post by:
Hi, I read data from a file into a 4 dimensional array. The data has a size of 5MB (could later be up to 500MB). I want to pass the matrix to subroutines. What is the cleverst (and for a...
0
by: =?Utf-8?B?U2llZ2ZyaWVkIEhlaW50emU=?= | last post by:
I think SetWorldTransform/GetWorldTransform/ModifyWorldTransform are the functions I want. Does anyone have an example that implements a stack? (1) I want to call SetWorldTransform in...
2
by: rijaalu | last post by:
I am designing a matrix class that performs addition, multicpication, substraction and division. When ever i complie the code it shows an error. include <iostream> using namespace std; class...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.