In English, "bread" can be a synonym for "meal" or "food" (and for "money", though that's a later innovation), as evidenced by the line from the Lord's Prayer, "Give us this day our daily bread."
In Japanese, "gohan" is both (cooked) "rice" and "meal": "Gohan wo tabeta?" "[Have you] eaten a meal?" (Transliterated; a more natural rendering would be "Have you eaten?")
An article in a recent issue of Science, talking about bananas, informs me that in Uganda the word for "banana" is the same as the word for "food". Sadly, the article didn't give the word for it, or even name the language (presumably Swahili).
I read the article on the train on the way home yesterday, and when I got home I was dying for a banana. Fortunately, Mayumi had bought bananas. Unfortunately, my girls managed eat all of them before I got home :-).
That's perhaps an allegory for what's happening worldwide: the Cavendish banana, the most common around the world, is under attack by a fungus all over the planet. The plant can be grown only by cloning (it's sterile) and since all the plants are genetically identical, they are all equally susceptible.
Other strains of bananas might be less vulnerable, but are suffering from neglect. (The most fragrant bananas I've ever had were in Nepal, some small variety that smelled of cinnamon.) Let's not let the world's fourth-most-important staple crop (behind rice, wheat and corn) get away from us, people!
Friday, November 28, 2008
guGUttara?
"To google" is now a verb in English (at least, the American (correct) form of the language, not sure about other parts of the diaspora). "He googled it," "I'm googling it now...," "Why don't you google it?" and more.
The same thing is true in Japanese. "Google" in Japanese is "GUUguru" (or "GU-guru"), written in katakana, the syllabary used for "loan" (imported) words, with a long "uu" and the unfortunate but necessary mangling of the pronunciation. (Not that Americans can come close to pronouncing Chinese or even French correctly, but that's not the point here.)
By fortunate coincidence, "-ru" is the common ending for verbs in Japanese, so conjugating it is natural and trivial, but the emphasized syllable changes: "guGUrimasu", "guGUrimashita". You almost never hear the formal form of it, though, you usually hear the informal form "guGUtta" ("googled") or "guGUtte iru" ("am googling/is googling"). Japanese has a verb form (not sure of the technical name in either Japanese or English) for "why don't you..." or "if you...", which usually ends in "-ttara".
And if you don't believe me, guguttara?
The same thing is true in Japanese. "Google" in Japanese is "GUUguru" (or "GU-guru"), written in katakana, the syllabary used for "loan" (imported) words, with a long "uu" and the unfortunate but necessary mangling of the pronunciation. (Not that Americans can come close to pronouncing Chinese or even French correctly, but that's not the point here.)
By fortunate coincidence, "-ru" is the common ending for verbs in Japanese, so conjugating it is natural and trivial, but the emphasized syllable changes: "guGUrimasu", "guGUrimashita". You almost never hear the formal form of it, though, you usually hear the informal form "guGUtta" ("googled") or "guGUtte iru" ("am googling/is googling"). Japanese has a verb form (not sure of the technical name in either Japanese or English) for "why don't you..." or "if you...", which usually ends in "-ttara".
And if you don't believe me, guguttara?
Monday, November 24, 2008
ORF: QKD with IPsec
Our campus (Keio's Shonan Fujisawa Campus) just finished our Open Research Forum, the annual two-day big exhibit of students' work. It was a blast, a lot of interesting people show up (including, if I understood him right, the director of "Godzilla versus Hedora", and it's great to see the work being done by students in other "kenkyuukai" (research groups), as well.
At our campus, undergrads, usually, starting in their second year, join the "lab" or kenkyuukai of a professor, and by the end of their four years, I would say that many students have done a third to a half of their total learning in the context of the kenykyuukai. Classes provide breadth and theory, the kenkyuukai provides depth.
My students in the AQUA group integrated IKE, the Internet Key Exchange protocol, with QKD (quantum key distribution), so that traffic between two networks can be encrypted using a key created via QKD. I'll post more about the technical work on it a little later, but thanks to Satoh and especially Nagayama for the hard work on both the implementation and the display.
Thanks to NEC for the loan of the QKD devices! We look forward to continuing to work with you.
At our campus, undergrads, usually, starting in their second year, join the "lab" or kenkyuukai of a professor, and by the end of their four years, I would say that many students have done a third to a half of their total learning in the context of the kenykyuukai. Classes provide breadth and theory, the kenkyuukai provides depth.
My students in the AQUA group integrated IKE, the Internet Key Exchange protocol, with QKD (quantum key distribution), so that traffic between two networks can be encrypted using a key created via QKD. I'll post more about the technical work on it a little later, but thanks to Satoh and especially Nagayama for the hard work on both the implementation and the display.
Thanks to NEC for the loan of the QKD devices! We look forward to continuing to work with you.
Monday, November 10, 2008
Keio: Astronauts, Princes, Emperors, and Postage Stamps!
So, Saturday was the Keio University 150th anniversary ceremony. I didn't get to attend (there were only a few thousand tickets), and I found out about the live webcast after it was over. Oh, well.
I'm told that the Emperor made very nice remarks about the history of Keio.
Prince Charles also dropped by the Mita Campus on his visit to Japan a couple of weeks ago. There is a good photo of him examining a bamboo sword during a kendo demonstration. I heard that his talk was nice, as well.
Just as exciting, to me, was the talk that Akihiko Hoshide gave a few weeks ago. He was on the team that delivered the Kibo Laboratory module to the International Space Station this summer. He also took an aluminum soroban with him, made for him by our engineering department. Oh, Hoshide is a Keio grad -- at least the second to fly in space, after Chiaki Mukai. Hoshide-san gave a great, inspirational talk targeted at kids, and accessible to all ages. It was broadcast over the Internet, and translated into several languages in real time.
More to my surprise, the Japan Post Office has issued a commemorative stamp set. Now I know what I'm getting my great-aunt, the stamp collector, for Christmas.
I'm told that the Emperor made very nice remarks about the history of Keio.
Prince Charles also dropped by the Mita Campus on his visit to Japan a couple of weeks ago. There is a good photo of him examining a bamboo sword during a kendo demonstration. I heard that his talk was nice, as well.
Just as exciting, to me, was the talk that Akihiko Hoshide gave a few weeks ago. He was on the team that delivered the Kibo Laboratory module to the International Space Station this summer. He also took an aluminum soroban with him, made for him by our engineering department. Oh, Hoshide is a Keio grad -- at least the second to fly in space, after Chiaki Mukai. Hoshide-san gave a great, inspirational talk targeted at kids, and accessible to all ages. It was broadcast over the Internet, and translated into several languages in real time.
More to my surprise, the Japan Post Office has issued a commemorative stamp set. Now I know what I'm getting my great-aunt, the stamp collector, for Christmas.
Friday, September 26, 2008
New Papers
It occurs to me that I'm behind in doing the obligatory paper dance, as our pontiff would say. All from collaborators, one already published and two new submissions:
More to come in the next couple of months, I hope, on both repeaters and arithmetic circuits; there is also a pile of systems work from last year's QEC conference and other places that needs to be polished up and submitted, as well as a stack of half-completed things...
...ah, for a trio of clones! Then one of us could teach, one could spend time with the family, one could do research, and one would have to do the drudge work. I suppose we'd have to rotate; I love all three of those first topics, but no one would want to be stuck with the paperwork forever :-).
- Byung-Soo Choi and Rodney Van Meter,
Effects of Interaction Distance on Quantum Addition Circuits,
submitted;
available from the arXiv as quant-ph:0809.4317.
- Liang Jiang, Jacob M. Taylor, Kae Nemoto, William J. Munro, Rodney Van Meter, and Mikhail D. Lukin,
Quantum Repeater with Encoding,
submitted;
available from the arXiv as quant-ph:0809.3629.
- W. J. Munro, R. Van Meter, Sebastien G. R. Louis, and Kae Nemoto,
High-Bandwidth Hybrid Quantum Repeater,
Phys. Rev. Letters 101, 040502, July 2008;
available from the arXiv as quant-ph:0808.0307.
Selected for Virtual J. Quantum Inf. 8(8), Aug. 2008.
More to come in the next couple of months, I hope, on both repeaters and arithmetic circuits; there is also a pile of systems work from last year's QEC conference and other places that needs to be polished up and submitted, as well as a stack of half-completed things...
...ah, for a trio of clones! Then one of us could teach, one could spend time with the family, one could do research, and one would have to do the drudge work. I suppose we'd have to rotate; I love all three of those first topics, but no one would want to be stuck with the paperwork forever :-).
Wednesday, September 24, 2008
Biden's Travels
I'm not going to get into politics on this blog, but one note: Joe Biden's team released a list of heads of state he has met with.
Now, the team claims the list is incomplete, but as an expat living where I do, there is a conspicuous hole: um, Japan? I realize that prime ministers here change often enough that it's difficult to keep up, but Japan is still the second biggest economy on the planet, and one of the U.S.'s top trading and defense partners.
Has Biden really not met with any Japanese leaders, or is the absence an oversight? It's not that he's shunning East, South, or Southeast Asia; he's met with leaders from almost every Asian country you can name, except Bangladesh and Thailand. Okay, he's allowed to not hit every single one; but still, Japan?
Likewise, another near the top of any U.S. list should be that Neighbor to the North, Canada. Hmm.
Now, the team claims the list is incomplete, but as an expat living where I do, there is a conspicuous hole: um, Japan? I realize that prime ministers here change often enough that it's difficult to keep up, but Japan is still the second biggest economy on the planet, and one of the U.S.'s top trading and defense partners.
Has Biden really not met with any Japanese leaders, or is the absence an oversight? It's not that he's shunning East, South, or Southeast Asia; he's met with leaders from almost every Asian country you can name, except Bangladesh and Thailand. Okay, he's allowed to not hit every single one; but still, Japan?
Likewise, another near the top of any U.S. list should be that Neighbor to the North, Canada. Hmm.
Monday, September 22, 2008
Sunday, September 21, 2008
No comment?
I'm a little disappointed that my glamorous new profile photo here hasn't drawn the attention of Paris, Milan and New York runway talent scouts.
I'm also a little surprised by the lack of comments from the peanut gallery.
I'm also a little surprised by the lack of comments from the peanut gallery.
The Candidate of Change
No, for you myopic Americans, I'm not talking about Obama, McCain, or anyone else on that continent. I'm talking about Yuriko Koike, a candidate for president of the Liberal Democratic Party here in Japan. She has held several cabinet positions, and is fluent in both Arabic and English, having received her degree from Cairo University. She's a bit of a long shot, but is supported by Koizumi, the former prime minister, who is still very popular. And, she has been dubbed the candidate of change, which many people would agree is desirable in Japanese politics.
The LDP's internal presidential election is tomorrow (Monday), Japan time. The rules for that election are apparently variable from election to election, but involve mostly members of parliament, and some local leaders, I believe. Taro Aso is expected to win.
Because the LDP is still the largest and strongest political party here, the person elected president normally becomes prime minister. Could Japan wind up with a woman chief executive before America does? Stay tuned.
The LDP's internal presidential election is tomorrow (Monday), Japan time. The rules for that election are apparently variable from election to election, but involve mostly members of parliament, and some local leaders, I believe. Taro Aso is expected to win.
Because the LDP is still the largest and strongest political party here, the person elected president normally becomes prime minister. Could Japan wind up with a woman chief executive before America does? Stay tuned.
Quantum Arithmetic
I get occasional mail from people asking me about quantum arithmetic. I usually point them to the Qwiki page on arithmetic I created a couple of years ago, which is a list of useful papers, rather than an actual technical description.
Most of the papers there are about specific arithmetic circuits, building from binary integer addition to modular exponentiation, and include some examples of actual experimental implementations.
This morning, I ran across some lecture notes by Ekert, Hayden, and Inamori on "Basic concepts in quantum computation," at Quantiki. The notes contain a nice intro to the theory behind reversible, binary, modular arithmetic.
Most of the papers there are about specific arithmetic circuits, building from binary integer addition to modular exponentiation, and include some examples of actual experimental implementations.
This morning, I ran across some lecture notes by Ekert, Hayden, and Inamori on "Basic concepts in quantum computation," at Quantiki. The notes contain a nice intro to the theory behind reversible, binary, modular arithmetic.
Wednesday, September 17, 2008
Competitiveness
BusinessWeek asks, "Is the U.S. Losing Its Edge in Tech?"
But their online article doesn't include an obvious link to the actual report from the Economic Intelligence Unit, sponsored by the Business Software Alliance. It's titled, How technology sectors grow: benchmarking IT industry competitiveness 2008", which tells you a little about their mindset.
Both the detailed data and their chosen methodology are interesting, though I haven't had time to digest them yet. The top 21 in their total index:
1. U.S.
2. Taiwan
3. U.K.
4. Sweden
5. Denmark
6. Canada
7. Australia
8. South Korea
9. Singapore
10. Netherlands
11. Switzerland
12. Japan
13. Finland
14. Norway
15. Ireland
16. Israel
17. New Zealand
18. Austria
19. Germany
20. France
21. Hong Kong
India, Russia, and China are 48, 49, and 50.
The disparities in "human capital" and "R&D environment" are interesting.
Even more telling are the drops from last year's index -- Japan fell from 2nd to 12th, South Korea from 3rd to 8th, due at least partly to shifts in their methodology. As always in some ranking system, you can engineer the results to fit your intuition :-).
But their online article doesn't include an obvious link to the actual report from the Economic Intelligence Unit, sponsored by the Business Software Alliance. It's titled, How technology sectors grow: benchmarking IT industry competitiveness 2008", which tells you a little about their mindset.
Both the detailed data and their chosen methodology are interesting, though I haven't had time to digest them yet. The top 21 in their total index:
1. U.S.
2. Taiwan
3. U.K.
4. Sweden
5. Denmark
6. Canada
7. Australia
8. South Korea
9. Singapore
10. Netherlands
11. Switzerland
12. Japan
13. Finland
14. Norway
15. Ireland
16. Israel
17. New Zealand
18. Austria
19. Germany
20. France
21. Hong Kong
India, Russia, and China are 48, 49, and 50.
The disparities in "human capital" and "R&D environment" are interesting.
Even more telling are the drops from last year's index -- Japan fell from 2nd to 12th, South Korea from 3rd to 8th, due at least partly to shifts in their methodology. As always in some ranking system, you can engineer the results to fit your intuition :-).
Tuesday, September 09, 2008
Happy Anniversary
Today is the twentieth anniversary of the Morris Worm. At the time, I had recently moved from ISI's computing center into the MOSIS Project, giving up my position as a sysadmin and becoming a regular programmer on the research staff.
I did get called back in to help a little, but since we were using VMS, the fix for MOSIS was pretty easy: unplug the network, and go back to work. Other folks I worked with, including Dale Chase, Jim Koda, Tom Wisniewski, had a much rougher day, dealing with several BSD VAXen and a large number of Suns.
I did get called back in to help a little, but since we were using VMS, the fix for MOSIS was pretty easy: unplug the network, and go back to work. Other folks I worked with, including Dale Chase, Jim Koda, Tom Wisniewski, had a much rougher day, dealing with several BSD VAXen and a large number of Suns.
Saturday, September 06, 2008
No Colbert on Linux, No Olympics on Windows
So, I'm trying to watch "The Colbert Report", which features Flash video, on my Fedora 9 laptop.
No joy. npviewer.bin, the Firefox plugin for Flash video, crashes reliably. A little googling turns up that I'm not the only one with this problem -- it has been The Daily Show's Developers' Blog. (Whine: why is it always me?)
A few weeks ago, I wanted to watch the Olympics in some fashion besides Japanese broadcast. Went to MSNBC.com...dang, Silverlight. I only run Linux on my laptop. Grumble. Dig out the Windows XP laptop I have at work for doing the obligatory Word documents. Download Silverlight. Install. Crashes. Reliably. (Whine: why is it always me?)
Have I mentioned that I hate computers?
No joy. npviewer.bin, the Firefox plugin for Flash video, crashes reliably. A little googling turns up that I'm not the only one with this problem -- it has been The Daily Show's Developers' Blog. (Whine: why is it always me?)
A few weeks ago, I wanted to watch the Olympics in some fashion besides Japanese broadcast. Went to MSNBC.com...dang, Silverlight. I only run Linux on my laptop. Grumble. Dig out the Windows XP laptop I have at work for doing the obligatory Word documents. Download Silverlight. Install. Crashes. Reliably. (Whine: why is it always me?)
Have I mentioned that I hate computers?
Tuesday, August 19, 2008
Ten Million Bucks to Learn to Program...
...molecules.
Erik Winfree's DNA and Natural Algorithms Group at my alma mater is arguably already the best in the world at programming DNA; they publish in Nature and Science like clockwork. I don't know the U-Dub guys, but I assume they're good, too.
So, over the next few years, I expect marvelous advances. Good luck to them! We'll be watching and waiting.
Erik Winfree's DNA and Natural Algorithms Group at my alma mater is arguably already the best in the world at programming DNA; they publish in Nature and Science like clockwork. I don't know the U-Dub guys, but I assume they're good, too.
So, over the next few years, I expect marvelous advances. Good luck to them! We'll be watching and waiting.
Internet-connected Windshield Wipers
A couple of days ago, Vint Cerf appeared on The Guardian, talking about the future of the Internet (what else?). He mentioned that "Researchers in Japan recently proposed using data from vehicles' windscreen wipers and embedded GPS receivers to track the movement of weather systems through towns and cities with a precision never before possible. It may seem academic, but understanding the way severe weather, such as a typhoon, moves through a city could save lives."
That's the iCar project, headed by Kei Uehara, here in the Internet Research Lab at Keio's Shonan Fujisawa Campus. The project has been running for more than a decade, and has strong ties to industry groups. Current work includes industry standardization of the privacy aspects of information uploaded by probes attached to vehicles, and the like.
The particular tidbit about the windshield wiper info goes back to about the year 2000, I'm told. It has even been featured in short TV segments about the project.
The WIDE folks are visionaries, I tell ya :-).
That's the iCar project, headed by Kei Uehara, here in the Internet Research Lab at Keio's Shonan Fujisawa Campus. The project has been running for more than a decade, and has strong ties to industry groups. Current work includes industry standardization of the privacy aspects of information uploaded by probes attached to vehicles, and the like.
The particular tidbit about the windshield wiper info goes back to about the year 2000, I'm told. It has even been featured in short TV segments about the project.
The WIDE folks are visionaries, I tell ya :-).
Sunday, August 17, 2008
Tom Sawyer in Tokyo, via Karachi
Hiya bibliophiles,
I bought an old, red, hardback copy of Tom Sawyer in Jimbocho, the famous used book district of Tokyo, and have been reading it to my nine-year-old daughter. (To my intense delight, she begs me not to stop reading.)

It's undated, and unillustrated, and includes a few typographic mistakes or omissions (such as saying, "See the next page" for some illustration which doesn't exist).
Mine appears to use the same chapter headings as the Random edition, according to Mark West. It does not, btw, say "complete and unabridged" anywhere, but it certainly feels complete.
My guess, based on the age and condition, is that it was printed in the 1920s or 30s. Here's the title page:

It also includes an embossed seal, which I'm guessing is a bookseller's:

Pan-American Commercial, Inc.
Elphinstone Street
Karachi
According to Wikipedia, the name of Elphinstone Street was changed to Zaibunnisa Street in 1970, so presumably my copy passed through Pakistan in the 1960s or earlier, before coming to Japan. Quite a trek for a book.
Thought you would enjoy the tale.
(Yes, I tinkered with the lighting on the second image using Gimp. Apologies for the generally poor image quality; those were taken hand-held in low light. The camera and lens are fine, but I didn't have a tripod available last night, and didn't mess with the in-camera choice of lighting adjustment.)
I bought an old, red, hardback copy of Tom Sawyer in Jimbocho, the famous used book district of Tokyo, and have been reading it to my nine-year-old daughter. (To my intense delight, she begs me not to stop reading.)

It's undated, and unillustrated, and includes a few typographic mistakes or omissions (such as saying, "See the next page" for some illustration which doesn't exist).
Mine appears to use the same chapter headings as the Random edition, according to Mark West. It does not, btw, say "complete and unabridged" anywhere, but it certainly feels complete.
My guess, based on the age and condition, is that it was printed in the 1920s or 30s. Here's the title page:

It also includes an embossed seal, which I'm guessing is a bookseller's:

Pan-American Commercial, Inc.
Elphinstone Street
Karachi
According to Wikipedia, the name of Elphinstone Street was changed to Zaibunnisa Street in 1970, so presumably my copy passed through Pakistan in the 1960s or earlier, before coming to Japan. Quite a trek for a book.
Thought you would enjoy the tale.
(Yes, I tinkered with the lighting on the second image using Gimp. Apologies for the generally poor image quality; those were taken hand-held in low light. The camera and lens are fine, but I didn't have a tripod available last night, and didn't mess with the in-camera choice of lighting adjustment.)
Tuesday, August 05, 2008
25th MSST
Don't forget to register for the 25th IEEE Symposium on Massive Storage Systems and Technologies!
This conference series has a long history, and has produced some fascinating discussions, especially about very large datasets (particle physics and the like). This year, the symposium is moving to a different format. See the web site for details.
This conference series has a long history, and has produced some fascinating discussions, especially about very large datasets (particle physics and the like). This year, the symposium is moving to a different format. See the web site for details.
Wednesday, July 30, 2008
Boost graph bundle + write_graphviz
I couldn't find a decent example of using the new Boost Graph library "bundle" functionality with write_graphviz, so I created one:
// first, the standard libraries
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <iterator>
#include <vector>
#include <queue>
// boost and other semi-standards should go here
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/scoped_array.hpp>
#include <boost/graph/graphviz.hpp>
#include <sys/times.h>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
using std::string;
using std::vector;
using namespace boost;
using std::ostream;
using std::ofstream;
using std::multiset;
using std::pair;
using std::multimap;
using std::map;
struct City
{
string name;
int population;
vector<int> zipcodes;
};
struct Highway
{
string name;
double miles;
int speed_limit;
int lanes;
bool divided;
};
typedef boost::adjacency_list<
boost::listS, boost::vecS, boost::bidirectionalS,
City, Highway> Map;
void outputgraph(Map&);
main()
{
Map map; // load the map
bool inserted;
Map::vertex_descriptor v = add_vertex(map);
Map::edge_descriptor e;
map[v].name = "Troy";
map[v].population = 49170;
map[v].zipcodes.push_back(12180);
tie(e,inserted) = add_edge(v, v, map);
if (inserted) {
map[e].name = "I-87";
map[e].miles = 10;
map[e].speed_limit = 65;
map[e].lanes = 4;
map[e].divided = true;
}
vector<double> distances(num_vertices(map));
Map::vertex_descriptor from = *vertices(map).first;
dijkstra_shortest_paths(map, from,
weight_map(get(&Highway::miles, map))
.distance_map(make_iterator_property_map(distances.begin(),
get(vertex_index, map))));
graph_traits < Map >::vertex_iterator vi, vend;
for (tie(vi, vend) = vertices(map); vi != vend; ++vi) {
std::cout << "name " << map[*vi].name <<
", " << "population " << map[*vi].population;
}
std::cout << std::endl;
outputgraph(map);
}
struct my_node_writer {
// my_node_writer() {}
my_node_writer(Map& g_) : g (g_) {};
template <class Vertex>
void operator()(std::ostream& out, Vertex v) {
out << " [label=\"" << v << "\"]" << std::endl;
};
// bleah. I can't get references right...
// according to http://www.knowledgesearch.org/doc/examples.html
// it should be a reference here, not the type itself.
// but g++ either barfs, or the program segfaults.
Map g;
};
struct my_edge_writer {
my_edge_writer(Map& g_) : g (g_) {};
template <class Edge>
void operator()(std::ostream& out, Edge e) {
// just an example, showing that local options override global
out << " [color=purple]" << std::endl;
out << " [label=\"" << e <<":" << g[e].miles << "\"]" << std::endl;
};
Map g;
};
struct my_graph_writer {
void operator()(std::ostream& out) const {
out << "graph [bgcolor=lightgrey]" << std::endl;
out << "node [shape=circle color=blue]" << std::endl;
// just an example, showing that local options override global
out << "edge [color=red]" << std::endl;
}
} myGraphWrite;
void outputgraph(Map& map){
std::ofstream gout;
gout.open("graphname.dot");
write_graphviz(gout,map,my_node_writer(map),my_edge_writer(map),myGraphWrite);
// std::cout() << "done writing graph" << std::endl;
}
foo.cpp |
// first, the standard libraries
#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <cmath>
#include <iterator>
#include <vector>
#include <queue>
// boost and other semi-standards should go here
#include <boost/scoped_ptr.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/shared_array.hpp>
#include <boost/scoped_array.hpp>
#include <boost/graph/graphviz.hpp>
#include <sys/times.h>
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>
using std::string;
using std::vector;
using namespace boost;
using std::ostream;
using std::ofstream;
using std::multiset;
using std::pair;
using std::multimap;
using std::map;
struct City
{
string name;
int population;
vector<int> zipcodes;
};
struct Highway
{
string name;
double miles;
int speed_limit;
int lanes;
bool divided;
};
typedef boost::adjacency_list<
boost::listS, boost::vecS, boost::bidirectionalS,
City, Highway> Map;
void outputgraph(Map&);
main()
{
Map map; // load the map
bool inserted;
Map::vertex_descriptor v = add_vertex(map);
Map::edge_descriptor e;
map[v].name = "Troy";
map[v].population = 49170;
map[v].zipcodes.push_back(12180);
tie(e,inserted) = add_edge(v, v, map);
if (inserted) {
map[e].name = "I-87";
map[e].miles = 10;
map[e].speed_limit = 65;
map[e].lanes = 4;
map[e].divided = true;
}
vector<double> distances(num_vertices(map));
Map::vertex_descriptor from = *vertices(map).first;
dijkstra_shortest_paths(map, from,
weight_map(get(&Highway::miles, map))
.distance_map(make_iterator_property_map(distances.begin(),
get(vertex_index, map))));
graph_traits < Map >::vertex_iterator vi, vend;
for (tie(vi, vend) = vertices(map); vi != vend; ++vi) {
std::cout << "name " << map[*vi].name <<
", " << "population " << map[*vi].population;
}
std::cout << std::endl;
outputgraph(map);
}
struct my_node_writer {
// my_node_writer() {}
my_node_writer(Map& g_) : g (g_) {};
template <class Vertex>
void operator()(std::ostream& out, Vertex v) {
out << " [label=\"" << v << "\"]" << std::endl;
};
// bleah. I can't get references right...
// according to http://www.knowledgesearch.org/doc/examples.html
// it should be a reference here, not the type itself.
// but g++ either barfs, or the program segfaults.
Map g;
};
struct my_edge_writer {
my_edge_writer(Map& g_) : g (g_) {};
template <class Edge>
void operator()(std::ostream& out, Edge e) {
// just an example, showing that local options override global
out << " [color=purple]" << std::endl;
out << " [label=\"" << e <<":" << g[e].miles << "\"]" << std::endl;
};
Map g;
};
struct my_graph_writer {
void operator()(std::ostream& out) const {
out << "graph [bgcolor=lightgrey]" << std::endl;
out << "node [shape=circle color=blue]" << std::endl;
// just an example, showing that local options override global
out << "edge [color=red]" << std::endl;
}
} myGraphWrite;
void outputgraph(Map& map){
std::ofstream gout;
gout.open("graphname.dot");
write_graphviz(gout,map,my_node_writer(map),my_edge_writer(map),myGraphWrite);
// std::cout() << "done writing graph" << std::endl;
}
Tuesday, May 27, 2008
Dr. Bono
Sir Paul David Hewson was at Keio's Mita Campus today, picking up an honorary doctorate for his humanitarian work. He is in town for the TICAD IV conference on African development.
I caught only a few minutes of his talk, but he talked about the new ONE Campaign and about bringing it to Japan. He singled out Tadao Ando and a couple of others by name as artists with a conscience whom he admires. He also talked about how wonderful the young Japanese people are, humble and wanting to help the world (he must have been talking to SFC students :-).
Bono is smart, dedicated, inspired, and inspiring. With leadership like him, and enough inspired young people, we can make the world a better place.
I caught only a few minutes of his talk, but he talked about the new ONE Campaign and about bringing it to Japan. He singled out Tadao Ando and a couple of others by name as artists with a conscience whom he admires. He also talked about how wonderful the young Japanese people are, humble and wanting to help the world (he must have been talking to SFC students :-).
Bono is smart, dedicated, inspired, and inspiring. With leadership like him, and enough inspired young people, we can make the world a better place.
Sunday, May 18, 2008
Subscribe to:
Posts (Atom)