LEDA graph v/s Boost Graph library [closed] - boost-graph

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I want efficiency and I am willing to write code by myself if efficiency (=0.9*speed + 0.1*others) is high. If I were to choose between LEDA graph or Boost graph, which one should I choose?
My algorithms are time-consuming (some are even non-polynomial in time) which works on large graphs.

Boost is generally a good library but I would not suggest Boost graph for a number of reasons.
The BGL documentation is execrable, with no easy to follow user guide. I have found that trying to define graphs with properties that are relevant to my own problems is very difficult.
You frequently end up with huge compiler errors that show templates within templates within templates ... nigh on impossible to see what is going on.
The only solution I found was to start with a trivial example that comes with Boost Graph, and adapt it until it does what I want.
I know of many bright and capable people that have ditched Boost Graph because of these reasons. Sad since there are very efficient algorithms underneath it all. For me BGL is the textbook example of template overuse. Boost Graph is a great idea that fails by missing the point entirely: code is worthless if it can't be read, maintained, extended, or debugged.
There are alternatives to LEDA/Boost implementation. You could do worse than to investigate this similar-sounding posting:
https://stackoverflow.com/questions/510758/can-you-suggest-a-good-book-on-graphs-and-graph-algorithms (link is no longer valid)

The Boost is continually refactored so parts of it get moved into the standard, after which vendor's continue to optimize it for the target systems they support. On rare usage scenarios, using inheritance the developer may tweak some part for specific case.
If the work is confined to C++, then as the parts of Boost are aiming to get integrated into the standard, it does have these advantages. There maybe specific reason to use proprietary LEDA, such as being guaranteed error free by testing, then as the decision maker only you have to observe such criteria.

Boost graph algorithms can be made to work on LEDA and even stanford graph base graphs, but not the other way around.
http://www.boost.org/doc/libs/1_46_1/libs/graph/doc/leda_conversion.html
I would suggest to use boost graph, it is the state of the art.
mike

Related

Creating containers c++ [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I'm wondering if creating my own container is very useful ? There are a few containers already implemented in c++ but what are the advantages of creating my own container ?
More information : I am a beginner.
Edit : can someone give me an example of what a Standard Library container can't do ?
If your intent is to learn about the containers and C++, by all means, go ahead and try to implement them. If you just want to use a container and it exists in the standard library, boost, or some other reputable library you have in your project, just use the library version. It's likely to be well tested and optimized. Other programmers are also likely to be more familiar with that container than something you roll out yourself.
A rule of thumb is, reuse code, unless you can do better and can justify the associated cost.
If you want to learn how to program, or understand how containers work, or everything related to them, then your own implementation of containers is a good practice.
However, large companies often also use their own containers, as they may consider standard containers and algorithms not optimal for their own tasks.
There are several non-standard containers in Boost, like the ones in Boost.Container or Boost Graph Library, so there's certainly some ground the STL doesn't cover.
Generally speaking, start with std::vector and check the other STL containers if it doesn't meet your requirements.
C++ Standard Library is a general purpose library for C++ programming language. In is designed to be well enough for most tasks you may encounter in your job. But sometimes it can turn out that some container from Standard Library does not fit your needs. This is the case when you can implement your own version of some container because Standard Library can't satisfy absolutely every need that can arise during your work.
I'm wondering if creating my own container is very useful ?
It could be.
My understanding of containers is template-s in C++ code
A simple example are matrixes. You may want to develop your own template<unsigned Height,unsigned Width,typeclass ElementType> class Matrix, and you would certainly call that a container. Remember that matrices of polynomial makes sense in mathematics.
A typical example is numerical scientific computations, related to representing huge mathematical symmetrical or triangular or diagonal or sparse (etc...) matrixes on various kind of numbers (float-s, but also bignums). Think of finite element methods computation.
The opencv library is an open source C++ library on computer vision which uses template-s. Download its source code and study it.
Another example is some heavy C++ software taking advantage of OpenCL (when that is available).
Or representing efficiently in memory a mathematical permutation between integers less than some given N. You may want to represent that as two std::vectors (one for the direct, another for the inverse mapping) inside your own template.
Some generic parsing libraries in C++ are heavily using templates.
The Qt graphical toolkit is coded in C++, is open source, and has template-s.
The tensorflow machine learning library has open source C++ code with template-s.
The Wt web toolkit is coded in C++, is open source, and uses template-s. You can download and study its source code. My opinion is that it has specialized containers.
The GCC compiler is coded mostly in C++, is free software, and uses template-s. You can download and study its source code. My opinion is that it has specialized containers.
A third example is garbage collection support. The RefPerSys project has templates...
A fourth example could be related to storing your C++ container in a database (like PostgreSQL)
Don't forget another approach: generating C++ code (like SWIG or ANTLR does) from some higher-level description. And be aware of the rule of five.
See also Autosar MISRA C++ coding guidelines.

What are the advantages of extending Python with C or C++? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Recently I've read that we can code C/C++ and from python call those modules, I know that C/C++ is fast and strongly typed and those things but what advantages I got if I code some module and then call it from python? in what case/scenario/context it would be nice to implement this?
Thanks in advance.
Performance. That's why NumPy is so fast ("The NumPy array: a structure for eļ¬ƒcient
numerical computation")
If you need to access a system library that doesn't have a wrapper
in python (Example: Shapely wraps around libgeos to do
geometrical computations), or if you're writing a wrapper around a
system library.
If you have a performance bottleneck in a function
that needs to be made a lot faster (and can benefit from using C).
Like Charlie said, profiling is essential to find out whether you
want to do this or not.
Profile your application. If it really is spending time in a couple of places that you can recode in C consider doing so. Don't do this unless profiling tells you you really need to.
Another reason is there might be a C/C++ library with functionality not available in python. You might write a python extension in C/C++ so that you can access/use that C/C++ library.
The primary advantage I see is speed. That's the price paid for the generality and flexibility of a dynamic language like Python. The execution model of the language doesn't match the execution model of the processor, by a wide margin, so there must be a translation layer someplace at runtime.
There are significant sections of work in many applications that can be encapsulated as strongly-typed functions. FFTs, convolutions, matrix operations and other types of array processing are good examples where a tightly-coded compiled loop can outperform a pure Python solution more than enough to pay for the runtime data copying and "environment switching" overhead.
There is also the case for "C as a portable assembler" to gain access to hardware functions for accelerating these functions. The Python library may have a high-level interface that depends on driver code that's not available widely enough to be part of the Python execution model. Multimedia hardware for video and audio processing, and array processing instructions on the CPU or GPU are examples.
The costs for a custom hybrid solution are in development and maintenance. There is added complexity in design, coding, building, debugging and deployment of the application. You also need expertise on-staff for two different programming languages.

Differences between Wrapper and Library [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
I am curious to know the differences between a Wrapper and a Library.
From what I have been able to find online I can't really see any major difference between the two. I often came across "Wrapper Library" or "Library Wrapper" and it makes it seem as if they are basically one in the same.
However, my assumption is that a Library is a collection of finely tuned functions that provide a means to accomplish a task that isn't part of the core functionality in the language.
And a Wrapper is a facade that makes it easier and quicker to set up certain functionality within your program so that you have less typing to do.
These two descriptions just make it seem like it's the same thing with different wording to me though.. so I come to you Stackoverflow,
What are your opinions and professional points of view on Wrappers/Libraries?
Sidenote/Background:
This question stems from my C++ Design Patterns Class I finished a month ago:
In my C++ Software Design Patterns class we had to create a Socket Library that took the WinSock Library and created a Thin(Or Thick, our choice) Wrapper over it. We then had to create two applications that used our library so that we didn't have to repeat the basic set up and tedious coding of the WinSock Library. I ended up with 100% on the project but wish to know more about the actual differences or similarities because I want to expand on this project in my personal time.
In general, I personally think of it like this:
A library is typically an actual concrete implementation of some functionality.
A wrapper is mostly just a layer of abstraction around existing functionality. It is only intended to offer a better, cleaner interface (or at least one feels more native to the language or technology it targets) to something that already exists.
Now obviously there are times when the distinction between the two is crystal clear and times when the line is blurred, so some subjectivity may be inevitable in the latter scenarios. In other words, what you consider an implementation and what you consider simply an abstraction can be ambiguous occasionally.
For instance, a wrapper can have argument checking functionality or better state bookkeeping that the underlying system did not have. If this is mostly to serve the correctness of the abstraction, then it this still leans on the side of the wrapper. If some genuinely new functionality is added, it starts becoming a library and could be called a wrapper-library.
On the other hand, a full-fledged library may not be a wrapper at all, in the sense that it may leverage an underlying system to offer some functionality, but without exposing any considerable part of that underlying system in any clean interface (other than the specific functionality it adds). This would be called a library, but most probably it wouldn't be called a wrapper.
(I should clarify that what I said is how I think of the matter in general, not specifically in regard to C++. If the C++ world has less ambiguous definitions of these terms, please do correct me.)
Library is an generic implementation of any sort of functionality. Wrapper is a specific implementation intended to provide abstraction to existing library.

C++ Adobe source libraries impressions? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
Improve this question
I just stumbled upon Adobe source libraries, ASL. It is set of templates and functions similar to boost, under MIT license.
Some of the utilities in the library I found quite useful and now I consider using it.
the library seems pretty straightforward, however.
Have you used ASL yourself? if so, what were your impressions? do you recommend it?
does it work well with a range of compilers and platforms e.g. IBM C++, ICC, g++?
have you encountered quirks/unexpected things?
thanks
ASL uses Boost heavily, so it's not such similar to Boost, as (in some cases) a relatively thin wrapper around Boost.
The "big" pieces of ASL are Adam and Eve. Most of the rest appears to be (and if memory serves, really is) little more than support for those.
ASL hasn't been updated in a while, and if I'm not mistaken some of what it provides in wrappers around Boost has now been incorporated into the Boost libraries themselves (most Boost authors have been aware of ASL at least since they featured in Sean Parent's keynote presentation at Boostcon 1).
My own experience with them has been somewhat mixed. At one time, I used a couple of their Boost-wrapper classes a bit, but IIRC, within the next release or two, the bits I cared about were available in Boost without any wrappers (though offhand, I don't remember exactly what those pieces were...)
Adam and Eve are kind of cool for playing around with different UI layouts and such -- but I've never used them for a finished version of a program. At least to me, it appears that they're useful primarily with a relatively complex UI. My impression was that if you find them very useful, your UI probably needs work. If you need Adam and Eve to help understand what's going on, chances are your users can't figure out either.
OTOH, there are probably at least a few cases where a dialog is clear to a user, but the code much less so to a developer. If you do a lot of disabling some controls until values have been entered in other controls, and such, it can make it a lot easier to ensure controls are disabled until all values they depend upon have been entered.
As already noted, thew whole point of ASL is Adam and Eve, the rest are just handy tools.
Adam & Eve work together to describe UI with auto-layout in a cross-platform way.
If this is not what you need, then you should probably not spend much time on ASL.
Eve has the typical collection of vertical/horizontal/other containers for auto-layout.
And scripting with Adam allows you to achieve things difficult (if not impossible) to achieve just with layout containers (things like keeping separate groups of controls the same size, for instance).
True, you implement some of the rules in your C++ code. But it makes sense to store the UI description rules related to UI behavior in the same place where you store the UI to begin with.

Markdown Implementations for C/C++ [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
What is the best implementation of Markdown for C or C++?
I found these via Google, and would appreciate comments about which ones work well and which ones don't (and which ones I may have missed):
peg-markdown
Discount
Cpp-Markdown
libsoldout (formerly libupskirt)
peg-markdown depends on GLib and other 3rd part tools. I've tested it, it works quite well.
Advantages:
Dual-licensed under GPL and MIT.
Uses internally formal grammar, so easy to maintain and extend.
Disadvantages:
Depends on GLib
Provides C API.
Cpp-Markdown, Most C++ code but it is quite slow and little bit bloated. On the other hand it is quite easy to understand and modify, Depends on boost-1.35.
Advantages
Depends only on boost
Written in C++, looks like less dangerous
Licensed under MIT.
Disadvantages
Slow (it is still about 10 times faster then Perl implementation, but about 10 times slower than Discount)
Discount, This is the code I use for my blog http://art-blog.no-ip.info/cppcms/blog and wiki http://art-blog.no-ip.info/wikipp/en/page/main. It is written by hardcore C programmer and quite hardly mantainable (even the developer activly maintains it).
Advantages
Extremely fast
Written in pure C (no 3rd part dependencies).
Actively maintained
Has permissive 3 clause BSD license
Disadvantages
Almost impossible to maintain (even I could remove/add some fatures).
Has only FILE API, so I should tweak the code to make it work with general buffer.
Licensed under 4 clause BSD license that is incompatible with GPL. It is problematic if you want to use it not as part of your GPL-ed software.
Why do I know them so much?
I'm developing CppCMS, so I need a good markdown to HTML convertor. When I picked one (Discount), it was the only solution. Since then I've needed to replace it due to licensing issues. That said, I still quite like it because it is the fastest Markdown solution.
P.S.: If you want C++ wrapper for Discount, take a look on http://cppcms.svn.sourceforge.net/viewvc/cppcms/cms/trunk/cxxmarkdown/, It is not the latest version, but it is already tweaked.
EDIT: I have just visited Discount site and I had found that it had added a non-FILE API as well. So now it is real library.
EDIT 2: If you find better implementation or write your own under FOSS license, let me know ;)
EDIT 3: as cloose commented, discount had changed the license to 3 clause BSD.